diff --git a/applet/contents/ui/ConnectionItem.qml b/applet/contents/ui/ConnectionItem.qml --- a/applet/contents/ui/ConnectionItem.qml +++ b/applet/contents/ui/ConnectionItem.qml @@ -255,7 +255,7 @@ DetailsText { anchors { left: parent.left - leftMargin: units.iconSizes.smallMedium + leftMargin: units.iconSizes.medium right: parent.right } details: ConnectionDetails diff --git a/applet/contents/ui/DetailsText.qml b/applet/contents/ui/DetailsText.qml --- a/applet/contents/ui/DetailsText.qml +++ b/applet/contents/ui/DetailsText.qml @@ -19,10 +19,11 @@ */ import QtQuick 2.2 +import QtQuick.Layouts 1.2 import org.kde.kquickcontrolsaddons 2.0 as KQuickControlsAddons import org.kde.plasma.components 2.0 as PlasmaComponents -Column { +ColumnLayout { property var details: [] KQuickControlsAddons.Clipboard { @@ -47,59 +48,31 @@ } } - Repeater { - id: repeater + GridLayout { + Layout.fillWidth: true + columns: 2 + rowSpacing: 0 + columnSpacing: 0 - property int contentHeight: 0 - property int longestString: 0 - - model: details.length / 2 - - Item { - anchors { - left: parent.left - right: parent.right - } - height: Math.max(detailNameLabel.height, detailValueLabel.height) + Repeater { + model: details.length PlasmaComponents.Label { - id: detailNameLabel - - anchors { - left: parent.left - leftMargin: repeater.longestString - paintedWidth + Math.round(units.gridUnit / 2) - } - height: paintedHeight - font.pointSize: theme.smallestFont.pointSize - horizontalAlignment: Text.AlignRight - text: details[index*2] + ": " - opacity: 0.6 - - Component.onCompleted: { - if (paintedWidth > repeater.longestString) { - repeater.longestString = paintedWidth - } - } - } - - PlasmaComponents.Label { - id: detailValueLabel - - anchors { - left: parent.left - right: parent.right - leftMargin: repeater.longestString + Math.round(units.gridUnit / 2) - } - height: paintedHeight + property var label: index % 2 === 0 + Layout.alignment: Qt.AlignRight + Layout.fillWidth: label ? false : true + height: undefined elide: Text.ElideRight font.pointSize: theme.smallestFont.pointSize - text: details[(index*2)+1] + horizontalAlignment: Text.AlignLeft + text: details[index] + (label ? ": " : "") + opacity: label ? 0.6 : 1 textFormat: Text.PlainText MouseArea { anchors.fill: parent acceptedButtons: Qt.RightButton - onPressed: contextMenu.show(this, detailValueLabel.text, mouse.x, mouse.y) + onPressed: contextMenu.show(this, details[index + (label ? 1 : 0)], mouse.x, mouse.y) } } }