fix tablet proxy choosing wrong root

This commit is contained in:
Dante Ruiz 2017-04-18 22:49:43 +01:00
parent 89fa6601b9
commit ce8dba21a0

View file

@ -410,40 +410,36 @@ void TabletProxy::loadQMLSource(const QVariant& path) {
} }
void TabletProxy::pushOntoStack(const QVariant& path) { void TabletProxy::pushOntoStack(const QVariant& path) {
if (_qmlTabletRoot) { QObject* root = nullptr;
auto stack = _qmlTabletRoot->findChild<QQuickItem*>("stack"); if (!_toolbarMode && _qmlTabletRoot) {
root = _qmlTabletRoot;
} else if (_toolbarMode && _desktopWindow) {
root = _desktopWindow->asQuickItem();
}
if (root) {
auto stack = root->findChild<QQuickItem*>("stack");
if (stack) { if (stack) {
QMetaObject::invokeMethod(stack, "pushSource", Q_ARG(const QVariant&, path)); QMetaObject::invokeMethod(stack, "pushSource", Q_ARG(const QVariant&, path));
} else { } else {
loadQMLSource(path); loadQMLSource(path);
} }
} else if (_desktopWindow) {
auto stack = _desktopWindow->asQuickItem()->findChild<QQuickItem*>("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 { } else {
qCDebug(scriptengine) << "tablet cannot push QML because _qmlTabletRoot or _desktopWindow is null"; qCDebug(scriptengine) << "tablet cannot push QML because _qmlTabletRoot or _desktopWindow is null";
} }
} }
void TabletProxy::popFromStack() { void TabletProxy::popFromStack() {
if (_qmlTabletRoot) { QObject* root = nullptr;
auto stack = _qmlTabletRoot->findChild<QQuickItem*>("stack"); if (!_toolbarMode && _qmlTabletRoot) {
if (stack) { root = _qmlTabletRoot;
QMetaObject::invokeMethod(stack, "popSource"); } else if (_toolbarMode && _desktopWindow) {
} else { root = _desktopWindow->asQuickItem();
qCDebug(scriptengine) << "tablet cannot push QML because _qmlTabletRoot doesn't have child stack"; }
}
} else if (_desktopWindow) { if (root) {
auto stack = _desktopWindow->asQuickItem()->findChild<QQuickItem*>("stack"); auto stack = root->findChild<QQuickItem*>("stack");
if (stack) { QMetaObject::invokeMethod(stack, "popSource");
QMetaObject::invokeMethod(stack, "popSource");
} else {
qCDebug(scriptengine) << "tablet cannot pop QML because _desktopWindow doesn't have child stack";
}
} else { } else {
qCDebug(scriptengine) << "tablet cannot pop QML because _qmlTabletRoot or _desktopWindow is null"; qCDebug(scriptengine) << "tablet cannot pop QML because _qmlTabletRoot or _desktopWindow is null";
} }