Fix QML warnings regarding use of anchors within layout

'Detected anchors on an item that is managed by a
layout. This is undefined behavior; use Layout.alignment
instead.'
This commit is contained in:
Martchus 2018-06-30 17:45:03 +02:00
parent db4b032179
commit 321d6fdd60
6 changed files with 35 additions and 28 deletions

View File

@ -2,30 +2,38 @@ import QtQuick 2.7
import QtQuick.Layouts 1.1
import org.kde.plasma.components 2.0 as PlasmaComponents
RowLayout {
Item {
id: detailItem
property string detailName: name ? name : ""
property string detailValue: detail ? detail : ""
spacing: theme.defaultFont.pointSize * 0.8
width: detailRow.implicitWidth
height: detailRow.implicitHeight
PlasmaComponents.Label {
Layout.preferredWidth: 100
Layout.leftMargin: units.iconSizes.smallMedium
text: detailName + ":"
font.pointSize: theme.defaultFont.pointSize * 0.8
font.weight: Font.DemiBold
horizontalAlignment: Qt.AlignRight
}
PlasmaComponents.Label {
Layout.fillWidth: true
text: detailValue
font.pointSize: theme.defaultFont.pointSize * 0.8
elide: Text.ElideRight
RowLayout {
id: detailRow
spacing: theme.defaultFont.pointSize * 0.8
PlasmaComponents.Label {
Layout.preferredWidth: 100
Layout.leftMargin: units.iconSizes.smallMedium
text: detailName + ":"
font.pointSize: theme.defaultFont.pointSize * 0.8
font.weight: Font.DemiBold
horizontalAlignment: Qt.AlignRight
}
PlasmaComponents.Label {
Layout.fillWidth: true
text: detailValue
font.pointSize: theme.defaultFont.pointSize * 0.8
elide: Text.ElideRight
}
}
MouseArea {
anchors.fill: parent
acceptedButtons: Qt.RightButton
anchors.fill: parent
onClicked: {
var view = detailItem.ListView.view
var coordinates = mapToItem(view, mouseX, mouseY)

View File

@ -33,12 +33,12 @@ Item {
PlasmaCore.IconItem {
Layout.preferredWidth: units.iconSizes.small
Layout.preferredHeight: units.iconSizes.small
anchors.verticalCenter: parent.verticalCenter
Layout.alignment: Qt.AlignVCenter | Qt.AlignLeft
source: statusIcon
}
PlasmaComponents.Label {
Layout.fillWidth: true
anchors.verticalCenter: parent.verticalCenter
Layout.alignment: Qt.AlignVCenter | Qt.AlignLeft
elide: Text.ElideRight
text: name
}
@ -49,7 +49,7 @@ Item {
height: implicitHeight
text: statusString
color: statusColor ? statusColor : PlasmaCore.ColorScope.textColor
anchors.verticalCenter: parent.verticalCenter
Layout.alignment: Qt.AlignVCenter | Qt.AlignLeft
}
Item {
width: 3

View File

@ -47,12 +47,12 @@ ColumnLayout {
PlasmaCore.IconItem {
Layout.preferredWidth: units.iconSizes.small
Layout.preferredHeight: units.iconSizes.small
anchors.verticalCenter: parent.verticalCenter
Layout.alignment: Qt.AlignVCenter | Qt.AlignLeft
source: statusIcon
}
PlasmaComponents.Label {
Layout.fillWidth: true
anchors.verticalCenter: parent.verticalCenter
Layout.alignment: Qt.AlignVCenter | Qt.AlignLeft
elide: Text.ElideRight
text: name
}
@ -64,7 +64,7 @@ ColumnLayout {
height: implicitHeight
text: statusString
color: statusColor ? statusColor : PlasmaCore.ColorScope.textColor
anchors.verticalCenter: parent.verticalCenter
Layout.alignment: Qt.AlignVCenter | Qt.AlignLeft
}
Item {
width: units.smallSpacing

View File

@ -34,7 +34,7 @@ Item {
RowLayout {
spacing: units.smallSpacing
PlasmaComponents.Label {
anchors.verticalCenter: parent.verticalCenter
Layout.alignment: Qt.AlignVCenter | Qt.AlignLeft
elide: Text.ElideRight
text: name ? name : "?"
}
@ -53,7 +53,7 @@ Item {
PlasmaComponents.Label {
height: implicitHeight
text: progressLabel ? progressLabel : ""
anchors.verticalCenter: parent.verticalCenter
Layout.alignment: Qt.AlignVCenter | Qt.AlignLeft
}
Item {
width: 3
@ -85,7 +85,7 @@ Item {
PlasmaCore.IconItem {
Layout.preferredWidth: units.iconSizes.medium
Layout.preferredHeight: units.iconSizes.medium
anchors.verticalCenter: parent.verticalCenter
Layout.alignment: Qt.AlignVCenter | Qt.AlignLeft
source: fileIcon
}
ColumnLayout {

View File

@ -481,7 +481,7 @@ ColumnLayout {
PlasmaComponents.TabBar {
id: tabBar
tabPosition: Qt.LeftEdge
anchors.top: parent.top
Layout.alignment: Qt.AlignTop | Qt.AlignLeft
PlasmaComponents.TabButton {
id: dirsTabButton

View File

@ -1,4 +1,3 @@
// This is a simplified and adjusted version of Plasma's ToolButtonStyle.
// It will make the button only as big as required and allows to disable
// padding. This makes the button a little bit more compact. Additionally,
@ -52,7 +51,7 @@ QtQuickControlStyle.ButtonStyle {
PlasmaComponents.Label {
id: label
anchors.verticalCenter: parent.verticalCenter
Layout.alignment: Qt.AlignVCenter
text: control.text
textFormat: Text.StyledText
font: control.font || theme.defaultFont