From 321d6fdd6041ef99092653e713e1c80e3379285d Mon Sep 17 00:00:00 2001 From: Martchus Date: Sat, 30 Jun 2018 17:45:03 +0200 Subject: [PATCH] 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.' --- plasmoid/package/contents/ui/DetailItem.qml | 40 +++++++++++-------- plasmoid/package/contents/ui/DevicesPage.qml | 6 +-- .../package/contents/ui/DirectoriesPage.qml | 6 +-- .../package/contents/ui/DownloadsPage.qml | 6 +-- .../contents/ui/FullRepresentation.qml | 2 +- .../package/contents/ui/TinyButtonStyle.qml | 3 +- 6 files changed, 35 insertions(+), 28 deletions(-) diff --git a/plasmoid/package/contents/ui/DetailItem.qml b/plasmoid/package/contents/ui/DetailItem.qml index 44ed2d2..e4843a7 100644 --- a/plasmoid/package/contents/ui/DetailItem.qml +++ b/plasmoid/package/contents/ui/DetailItem.qml @@ -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) diff --git a/plasmoid/package/contents/ui/DevicesPage.qml b/plasmoid/package/contents/ui/DevicesPage.qml index 616f7ac..b22ae16 100644 --- a/plasmoid/package/contents/ui/DevicesPage.qml +++ b/plasmoid/package/contents/ui/DevicesPage.qml @@ -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 diff --git a/plasmoid/package/contents/ui/DirectoriesPage.qml b/plasmoid/package/contents/ui/DirectoriesPage.qml index 7626aad..aa95c3b 100644 --- a/plasmoid/package/contents/ui/DirectoriesPage.qml +++ b/plasmoid/package/contents/ui/DirectoriesPage.qml @@ -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 diff --git a/plasmoid/package/contents/ui/DownloadsPage.qml b/plasmoid/package/contents/ui/DownloadsPage.qml index 2d0aee9..9f6d767 100644 --- a/plasmoid/package/contents/ui/DownloadsPage.qml +++ b/plasmoid/package/contents/ui/DownloadsPage.qml @@ -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 { diff --git a/plasmoid/package/contents/ui/FullRepresentation.qml b/plasmoid/package/contents/ui/FullRepresentation.qml index 9f54a6b..1b82e14 100644 --- a/plasmoid/package/contents/ui/FullRepresentation.qml +++ b/plasmoid/package/contents/ui/FullRepresentation.qml @@ -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 diff --git a/plasmoid/package/contents/ui/TinyButtonStyle.qml b/plasmoid/package/contents/ui/TinyButtonStyle.qml index 192807a..767534b 100644 --- a/plasmoid/package/contents/ui/TinyButtonStyle.qml +++ b/plasmoid/package/contents/ui/TinyButtonStyle.qml @@ -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