From ce8dba21a0f1a273817cd5c1198035843021fe8b Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Tue, 18 Apr 2017 22:49:43 +0100 Subject: [PATCH] fix tablet proxy choosing wrong root --- .../src/TabletScriptingInterface.cpp | 42 +++++++++---------- 1 file changed, 19 insertions(+), 23 deletions(-) diff --git a/libraries/script-engine/src/TabletScriptingInterface.cpp b/libraries/script-engine/src/TabletScriptingInterface.cpp index e744e83ebb..60e40c76f5 100644 --- a/libraries/script-engine/src/TabletScriptingInterface.cpp +++ b/libraries/script-engine/src/TabletScriptingInterface.cpp @@ -410,40 +410,36 @@ void TabletProxy::loadQMLSource(const QVariant& path) { } void TabletProxy::pushOntoStack(const QVariant& path) { - if (_qmlTabletRoot) { - auto stack = _qmlTabletRoot->findChild("stack"); + QObject* root = nullptr; + if (!_toolbarMode && _qmlTabletRoot) { + root = _qmlTabletRoot; + } else if (_toolbarMode && _desktopWindow) { + root = _desktopWindow->asQuickItem(); + } + + if (root) { + auto stack = root->findChild("stack"); if (stack) { QMetaObject::invokeMethod(stack, "pushSource", Q_ARG(const QVariant&, path)); } else { loadQMLSource(path); } - } else if (_desktopWindow) { - auto stack = _desktopWindow->asQuickItem()->findChild("stack"); - if (stack) { - QMetaObject::invokeMethod(stack, "pushSource", Q_ARG(const QVariant&, path)); - } else { - qCDebug(scriptengine) << "tablet cannot push QML because _desktopWindow doesn't have child stack"; - } } else { qCDebug(scriptengine) << "tablet cannot push QML because _qmlTabletRoot or _desktopWindow is null"; } } void TabletProxy::popFromStack() { - if (_qmlTabletRoot) { - auto stack = _qmlTabletRoot->findChild("stack"); - if (stack) { - QMetaObject::invokeMethod(stack, "popSource"); - } else { - qCDebug(scriptengine) << "tablet cannot push QML because _qmlTabletRoot doesn't have child stack"; - } - } else if (_desktopWindow) { - auto stack = _desktopWindow->asQuickItem()->findChild("stack"); - if (stack) { - QMetaObject::invokeMethod(stack, "popSource"); - } else { - qCDebug(scriptengine) << "tablet cannot pop QML because _desktopWindow doesn't have child stack"; - } + QObject* root = nullptr; + if (!_toolbarMode && _qmlTabletRoot) { + root = _qmlTabletRoot; + } else if (_toolbarMode && _desktopWindow) { + root = _desktopWindow->asQuickItem(); + } + + if (root) { + auto stack = root->findChild("stack"); + QMetaObject::invokeMethod(stack, "popSource"); } else { qCDebug(scriptengine) << "tablet cannot pop QML because _qmlTabletRoot or _desktopWindow is null"; }