QML UI: don't use anchors within Layouts

Qt 5.11 adds useful warnings when code attempts to use anchors within
Layouts and even tells you how to fix things.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2018-06-25 16:41:29 +08:00
parent cda1961d80
commit f998b59900
2 changed files with 10 additions and 24 deletions

View file

@ -97,9 +97,8 @@ Item {
} }
RowLayout { RowLayout {
anchors.left: parent.left Layout.fillWidth: true
anchors.right: parent.right Layout.margins: Kirigami.Units.smallSpacing
anchors.margins: Kirigami.Units.smallSpacing
spacing: Kirigami.Units.smallSpacing spacing: Kirigami.Units.smallSpacing
visible: rootItem.showPin visible: rootItem.showPin
SsrfButton { SsrfButton {
@ -124,9 +123,8 @@ Item {
} }
RowLayout { RowLayout {
anchors.left: parent.left Layout.fillWidth: true
anchors.right: parent.right Layout.margins: Kirigami.Units.smallSpacing
anchors.margins: Kirigami.Units.smallSpacing
spacing: Kirigami.Units.smallSpacing spacing: Kirigami.Units.smallSpacing
visible: !rootItem.showPin visible: !rootItem.showPin

View file

@ -49,10 +49,8 @@ Kirigami.Page {
Layout.fillWidth: true Layout.fillWidth: true
GridLayout { GridLayout {
id: buttonGrid id: buttonGrid
anchors { Layout.alignment: Qt.AlignTop
top: parent.top Layout.topMargin: Kirigami.Units.smallSpacing * 4
topMargin: Kirigami.Units.smallSpacing * 4
}
columns: 2 columns: 2
Controls.Label { text: qsTr(" Vendor name: ") } Controls.Label { text: qsTr(" Vendor name: ") }
Controls.ComboBox { Controls.ComboBox {
@ -163,11 +161,8 @@ Kirigami.Page {
} }
Controls.ProgressBar { Controls.ProgressBar {
anchors {
top: buttonGrid.bottom
topMargin: Kirigami.Units.smallSpacing * 4
}
id: progressBar id: progressBar
Layout.topMargin: Kirigami.Units.smallSpacing * 4
Layout.fillWidth: true Layout.fillWidth: true
indeterminate: true indeterminate: true
visible: false visible: false
@ -175,12 +170,8 @@ Kirigami.Page {
RowLayout { RowLayout {
id: buttonBar id: buttonBar
anchors { Layout.fillWidth: true
left: parent.left Layout.topMargin: Kirigami.Units.smallSpacing * 2
right: parent.right
top: progressBar.bottom
topMargin: Kirigami.Units.smallSpacing * 2
}
spacing: Kirigami.Units.smallSpacing spacing: Kirigami.Units.smallSpacing
SsrfButton { SsrfButton {
id: download id: download
@ -227,10 +218,7 @@ Kirigami.Page {
ListView { ListView {
id: dlList id: dlList
anchors { Layout.topMargin: Kirigami.Units.smallSpacing * 4
top: buttonBar.bottom
topMargin: Kirigami.Units.smallSpacing * 4
}
Layout.bottomMargin: bottomButtons.height * 1.5 Layout.bottomMargin: bottomButtons.height * 1.5
Layout.fillWidth: true Layout.fillWidth: true
Layout.fillHeight: true Layout.fillHeight: true