From 1d94903eefcd1b7bcb5ee0c8b2f4fd1fc290fbeb Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Sat, 30 Mar 2019 12:28:18 -0700 Subject: [PATCH] Add a hack to ensure the layout anchors work properly on Qt 5.11 and earlier --- app/gui/AppView.qml | 12 ++++++++++++ app/gui/PcView.qml | 12 ++++++++++++ 2 files changed, 24 insertions(+) diff --git a/app/gui/AppView.qml b/app/gui/AppView.qml index af546340..5f7028ef 100644 --- a/app/gui/AppView.qml +++ b/app/gui/AppView.qml @@ -30,6 +30,18 @@ GridView { // We do this here instead of onActivated to avoid losing the user's // selection when backing out of a different page of the app. currentIndex = -1 + + // HACK: If this is not Qt 5.12 (which has synchronousDrag), + // set anchors on creation. This will cause an anchor conflict + // with the parent StackView which breaks animation, but otherwise + // the grid will not be centered in the window. + if (this.synchronousDrag === undefined) { + anchors.fill = parent + anchors.leftMargin = leftMargin + anchors.rightMargin = rightMargin + anchors.topMargin = topMargin + anchors.bottomMargin = bottomMargin + } } StackView.onActivated: { diff --git a/app/gui/PcView.qml b/app/gui/PcView.qml index 2693d8b7..14ace787 100644 --- a/app/gui/PcView.qml +++ b/app/gui/PcView.qml @@ -27,6 +27,18 @@ GridView { // We do this here instead of onActivated to avoid losing the user's // selection when backing out of a different page of the app. currentIndex = -1 + + // HACK: If this is not Qt 5.12 (which has synchronousDrag), + // set anchors on creation. This will cause an anchor conflict + // with the parent StackView which breaks animation, but otherwise + // the grid will not be centered in the window. + if (this.synchronousDrag === undefined) { + anchors.fill = parent + anchors.leftMargin = leftMargin + anchors.rightMargin = rightMargin + anchors.topMargin = topMargin + anchors.bottomMargin = bottomMargin + } } StackView.onActivated: {