mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 08:21:24 +02:00
fix fix-snap-html-issue
This commit is contained in:
parent
058c74f7d2
commit
fe2a4c3600
6 changed files with 91 additions and 26 deletions
|
@ -19,6 +19,7 @@ StackView {
|
||||||
objectName: "stack"
|
objectName: "stack"
|
||||||
property string title: "General Settings"
|
property string title: "General Settings"
|
||||||
property alias gotoPreviousApp: root.gotoPreviousApp;
|
property alias gotoPreviousApp: root.gotoPreviousApp;
|
||||||
|
property alias gotoPreviousAppFromScript: root.gotoPreviousAppFromScript;
|
||||||
signal sendToScript(var message);
|
signal sendToScript(var message);
|
||||||
|
|
||||||
function pushSource(path) {
|
function pushSource(path) {
|
||||||
|
@ -30,6 +31,10 @@ StackView {
|
||||||
profileRoot.pop();
|
profileRoot.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function emitSendToScript(message) {
|
||||||
|
profileRoot.sendToScript(message);
|
||||||
|
}
|
||||||
|
|
||||||
TabletPreferencesDialog {
|
TabletPreferencesDialog {
|
||||||
id: root
|
id: root
|
||||||
objectName: "TabletGeneralPreferences"
|
objectName: "TabletGeneralPreferences"
|
||||||
|
|
|
@ -104,6 +104,10 @@ Rectangle {
|
||||||
if (loader.item.hasOwnProperty("gotoPreviousApp")) {
|
if (loader.item.hasOwnProperty("gotoPreviousApp")) {
|
||||||
loader.item.gotoPreviousApp = true;
|
loader.item.gotoPreviousApp = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (loader.item.hasOwnProperty("gotoPreviousAppFromScript")) {
|
||||||
|
loader.item.gotoPreviousAppFromScript = true;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,7 @@ Item {
|
||||||
property bool keyboardRaised: false
|
property bool keyboardRaised: false
|
||||||
property bool punctuationMode: false
|
property bool punctuationMode: false
|
||||||
property bool gotoPreviousApp: false
|
property bool gotoPreviousApp: false
|
||||||
|
property bool gotoPreviousAppFromScript: false
|
||||||
|
|
||||||
property var tablet;
|
property var tablet;
|
||||||
|
|
||||||
|
@ -72,7 +73,9 @@ Item {
|
||||||
function closeDialog() {
|
function closeDialog() {
|
||||||
var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");
|
var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");
|
||||||
|
|
||||||
if (gotoPreviousApp) {
|
if (gotoPreviousAppFromScript) {
|
||||||
|
dialog.parent.sendToScript("returnToPreviousApp");
|
||||||
|
} else if (gotoPreviousApp) {
|
||||||
tablet.returnToPreviousApp();
|
tablet.returnToPreviousApp();
|
||||||
} else {
|
} else {
|
||||||
tablet.gotoHomeScreen();
|
tablet.gotoHomeScreen();
|
||||||
|
|
|
@ -592,9 +592,9 @@ void TabletProxy::gotoMenuScreen(const QString& submenu) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TabletProxy::loadQMLOnTop(const QVariant& path) {
|
void TabletProxy::loadQMLOnTopImpl(const QVariant& path, bool localSafeContext) {
|
||||||
if (QThread::currentThread() != thread()) {
|
if (QThread::currentThread() != thread()) {
|
||||||
QMetaObject::invokeMethod(this, "loadQMLOnTop", Q_ARG(QVariant, path));
|
qCWarning(uiLogging) << __FUNCTION__ << "may not be called directly by scripts";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -606,35 +606,65 @@ void TabletProxy::loadQMLOnTop(const QVariant& path) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (root) {
|
if (root) {
|
||||||
|
if (localSafeContext) {
|
||||||
|
hifi::scripting::setLocalAccessSafeThread(true);
|
||||||
|
}
|
||||||
QMetaObject::invokeMethod(root, "loadQMLOnTop", Q_ARG(const QVariant&, path));
|
QMetaObject::invokeMethod(root, "loadQMLOnTop", Q_ARG(const QVariant&, path));
|
||||||
QMetaObject::invokeMethod(root, "setShown", Q_ARG(const QVariant&, QVariant(true)));
|
QMetaObject::invokeMethod(root, "setShown", Q_ARG(const QVariant&, QVariant(true)));
|
||||||
if (_toolbarMode && _desktopWindow) {
|
if (_toolbarMode && _desktopWindow) {
|
||||||
QMetaObject::invokeMethod(root, "setResizable", Q_ARG(const QVariant&, QVariant(false)));
|
QMetaObject::invokeMethod(root, "setResizable", Q_ARG(const QVariant&, QVariant(false)));
|
||||||
}
|
}
|
||||||
|
hifi::scripting::setLocalAccessSafeThread(false);
|
||||||
|
} else {
|
||||||
|
qCDebug(uiLogging) << "tablet cannot load QML because _qmlTabletRoot is null";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TabletProxy::loadQMLOnTop(const QVariant& path) {
|
||||||
|
bool localSafeContext = hifi::scripting::isLocalAccessSafeThread();
|
||||||
|
if (QThread::currentThread() != thread()) {
|
||||||
|
QMetaObject::invokeMethod(this, "loadQMLOnTopImpl", Q_ARG(QVariant, path), Q_ARG(bool, localSafeContext));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
loadQMLOnTopImpl(path, localSafeContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TabletProxy::returnToPreviousAppImpl(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, "returnToPreviousApp");
|
||||||
|
QMetaObject::invokeMethod(root, "setShown", Q_ARG(const QVariant&, QVariant(true)));
|
||||||
|
hifi::scripting::setLocalAccessSafeThread(false);
|
||||||
} else {
|
} else {
|
||||||
qCDebug(uiLogging) << "tablet cannot load QML because _qmlTabletRoot is null";
|
qCDebug(uiLogging) << "tablet cannot load QML because _qmlTabletRoot is null";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TabletProxy::returnToPreviousApp() {
|
void TabletProxy::returnToPreviousApp() {
|
||||||
|
bool localSafeContext = hifi::scripting::isLocalAccessSafeThread();
|
||||||
|
qDebug() << "TabletProxy::returnToPreviousApp -> localSafeContext: " << localSafeContext;
|
||||||
if (QThread::currentThread() != thread()) {
|
if (QThread::currentThread() != thread()) {
|
||||||
QMetaObject::invokeMethod(this, "returnToPreviousApp");
|
QMetaObject::invokeMethod(this, "returnToPreviousAppImpl", Q_ARG(bool, localSafeContext));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QObject* root = nullptr;
|
returnToPreviousAppImpl(localSafeContext);
|
||||||
if (!_toolbarMode && _qmlTabletRoot) {
|
|
||||||
root = _qmlTabletRoot;
|
|
||||||
} else if (_toolbarMode && _desktopWindow) {
|
|
||||||
root = _desktopWindow->asQuickItem();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (root) {
|
|
||||||
QMetaObject::invokeMethod(root, "returnToPreviousApp");
|
|
||||||
QMetaObject::invokeMethod(root, "setShown", Q_ARG(const QVariant&, QVariant(true)));
|
|
||||||
} else {
|
|
||||||
qCDebug(uiLogging) << "tablet cannot load QML because _qmlTabletRoot is null";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TabletProxy::loadQMLSource(const QVariant& path, bool resizable) {
|
void TabletProxy::loadQMLSource(const QVariant& path, bool resizable) {
|
||||||
|
@ -940,8 +970,6 @@ void TabletProxy::sendToQml(const QVariant& msg) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
OffscreenQmlSurface* TabletProxy::getTabletSurface() {
|
OffscreenQmlSurface* TabletProxy::getTabletSurface() {
|
||||||
if (QThread::currentThread() != thread()) {
|
if (QThread::currentThread() != thread()) {
|
||||||
OffscreenQmlSurface* result = nullptr;
|
OffscreenQmlSurface* result = nullptr;
|
||||||
|
|
|
@ -298,10 +298,26 @@ public:
|
||||||
*/
|
*/
|
||||||
Q_INVOKABLE void loadQMLSourceImpl(const QVariant& path, bool resizable, bool localSafeContext);
|
Q_INVOKABLE void loadQMLSourceImpl(const QVariant& path, bool resizable, bool localSafeContext);
|
||||||
|
|
||||||
|
/**jsdoc
|
||||||
|
* Internal function, do not call from scripts
|
||||||
|
* @function TabletProxy#loadHTMLSourceImpl
|
||||||
|
*/
|
||||||
Q_INVOKABLE void loadHTMLSourceImpl(const QVariant& url, const QString& injectJavaScriptUrl, bool localSafeContext);
|
Q_INVOKABLE void loadHTMLSourceImpl(const QVariant& url, const QString& injectJavaScriptUrl, 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);
|
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
|
||||||
|
*/
|
||||||
|
Q_INVOKABLE void returnToPreviousAppImpl(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);
|
||||||
// it should be initialized internally so it cannot fail
|
// it should be initialized internally so it cannot fail
|
||||||
|
|
||||||
|
|
|
@ -65,6 +65,7 @@ function onMessage(message) {
|
||||||
// 2. Although we currently use a single image, we would like to take snapshot, a selfie, a 360 etc. all at the
|
// 2. Although we currently use a single image, we would like to take snapshot, a selfie, a 360 etc. all at the
|
||||||
// same time, show the user all of them, and have the user deselect any that they do not want to share.
|
// same time, show the user all of them, and have the user deselect any that they do not want to share.
|
||||||
// So we'll ultimately be receiving a set of objects, perhaps with different post processing for each.
|
// So we'll ultimately be receiving a set of objects, perhaps with different post processing for each.
|
||||||
|
|
||||||
if (message.type !== "snapshot") {
|
if (message.type !== "snapshot") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -274,6 +275,14 @@ var POLAROID_MODEL_URL = 'http://hifi-content.s3.amazonaws.com/alan/dev/Test/sna
|
||||||
var POLAROID_RATE_LIMIT_MS = 1000;
|
var POLAROID_RATE_LIMIT_MS = 1000;
|
||||||
var polaroidPrintingIsRateLimited = false;
|
var polaroidPrintingIsRateLimited = false;
|
||||||
|
|
||||||
|
// force call the gotoPreviousApp on script thead to load snapshot html page.
|
||||||
|
var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");
|
||||||
|
tablet.fromQml.connect(function(message) {
|
||||||
|
if (message === 'returnToPreviousApp') {
|
||||||
|
tablet.returnToPreviousApp();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
function printToPolaroid(image_url) {
|
function printToPolaroid(image_url) {
|
||||||
// Rate-limit printing
|
// Rate-limit printing
|
||||||
if (polaroidPrintingIsRateLimited) {
|
if (polaroidPrintingIsRateLimited) {
|
||||||
|
|
Loading…
Reference in a new issue