mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01: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* WEB_VIEW_SOURCE_URL = "hifi/tablet/TabletWebView.qml";
|
||||
static const char* VRMENU_SOURCE_URL = "hifi/tablet/TabletMenu.qml";
|
||||
|
||||
class TabletRootWindow : public QmlWindowClass {
|
||||
|
@ -827,58 +826,24 @@ void TabletProxy::loadWebScreenOnTop(const QVariant& url) {
|
|||
void TabletProxy::loadWebScreenOnTop(const QVariant& url, const QString& injectJavaScriptUrl) {
|
||||
bool localSafeContext = hifi::scripting::isLocalAccessSafeThread();
|
||||
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;
|
||||
}
|
||||
|
||||
loadHTMLSourceImpl(url, injectJavaScriptUrl, 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;
|
||||
loadHTMLSourceOnTopImpl(url.toString(), injectJavaScriptUrl, false, localSafeContext);
|
||||
}
|
||||
|
||||
void TabletProxy::gotoWebScreen(const QString& url, const QString& injectedJavaScriptUrl, bool loadOtherBase) {
|
||||
bool localSafeContext = hifi::scripting::isLocalAccessSafeThread();
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
loadHTMLSourceImpl(url, injectedJavaScriptUrl, loadOtherBase, localSafeContext);
|
||||
loadHTMLSourceOnTopImpl(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;
|
||||
if (!_toolbarMode && _qmlTabletRoot) {
|
||||
root = _qmlTabletRoot;
|
||||
|
@ -911,7 +876,6 @@ void TabletProxy::loadHTMLSourceImpl(const QString& url, const QString& injected
|
|||
_initialWebPathParams.first = injectedJavaScriptUrl;
|
||||
_initialWebPathParams.second = loadOtherBase;
|
||||
_initialScreen = true;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -273,7 +273,9 @@ public:
|
|||
Q_INVOKABLE void gotoHomeScreen();
|
||||
|
||||
/**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
|
||||
* @param {string} url - The URL of the web page or app.
|
||||
* @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);
|
||||
|
||||
/**jsdoc
|
||||
* Internal function, do not call from scripts
|
||||
* @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);
|
||||
|
||||
/**jsdoc
|
||||
* Internal function, do not call from scripts
|
||||
* @function TabletProxy#loadHTMLSourceImpl
|
||||
/**jsdoc
|
||||
* @function TabletProxy#loadHTMLSourceOnTopImpl
|
||||
* @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
|
||||
* 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
|
||||
/**jsdoc
|
||||
* @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);
|
||||
|
||||
/**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);
|
||||
|
||||
// FIXME: This currently relies on a script initializing the tablet (hence the bool denoting success);
|
||||
|
@ -355,8 +359,8 @@ public:
|
|||
|
||||
/**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
|
||||
* 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
|
||||
* {@link TabletProxy#returnToPreviousApp}.
|
||||
* 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#loadWebScreenOnTop
|
||||
* @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.
|
||||
|
|
Loading…
Reference in a new issue