Commit 2efaecee authored by George Vogiatzis's avatar George Vogiatzis Committed by Nate Graham

[Applet]Fix details layout.

Summary:
Fix binding loop with detailValueLabel's width.
Remove workaround for contentRect height.
Use Column as root item.
Remove unused topMargin.

Test Plan: Details of connections must remain the same.

Reviewers: #plasma, #vdg, jgrulich, ngraham

Reviewed By: #vdg, jgrulich, ngraham

Subscribers: ngraham, broulik, plasma-devel

Tags: #plasma

Maniphest Tasks: T10470

Differential Revision: https://phabricator.kde.org/D27393
parent 387609d1
......@@ -22,11 +22,9 @@ import QtQuick 2.2
import org.kde.kquickcontrolsaddons 2.0 as KQuickControlsAddons
import org.kde.plasma.components 2.0 as PlasmaComponents
Item {
Column {
property var details: []
height: repeater.contentHeight
KQuickControlsAddons.Clipboard {
id: clipboard
}
......@@ -49,70 +47,59 @@ Item {
}
}
Column {
anchors.fill: parent
Repeater {
id: repeater
property int contentHeight: 0
property int longestString: 0
Repeater {
id: repeater
model: details.length / 2
property int contentHeight: 0
property int longestString: 0
Item {
anchors {
left: parent.left
right: parent.right
}
height: Math.max(detailNameLabel.height, detailValueLabel.height)
model: details.length / 2
PlasmaComponents.Label {
id: detailNameLabel
Item {
anchors {
left: parent.left
right: parent.right
topMargin: Math.round(units.gridUnit / 3)
leftMargin: repeater.longestString - paintedWidth + Math.round(units.gridUnit / 2)
}
height: Math.max(detailNameLabel.height, detailValueLabel.height)
PlasmaComponents.Label {
id: detailNameLabel
anchors {
left: parent.left
leftMargin: repeater.longestString - paintedWidth + Math.round(units.gridUnit / 2)
verticalCenter: parent.verticalCenter
}
height: paintedHeight
font.pointSize: theme.smallestFont.pointSize
horizontalAlignment: Text.AlignRight
text: details[index*2] + ": "
Component.onCompleted: {
if (paintedWidth > repeater.longestString) {
repeater.longestString = paintedWidth
}
height: paintedHeight
font.pointSize: theme.smallestFont.pointSize
horizontalAlignment: Text.AlignRight
text: details[index*2] + ": "
Component.onCompleted: {
if (paintedWidth > repeater.longestString) {
repeater.longestString = paintedWidth
}
}
}
PlasmaComponents.Label {
id: detailValueLabel
PlasmaComponents.Label {
id: detailValueLabel
anchors {
left: detailNameLabel.right
right: parent.right
verticalCenter: parent.verticalCenter
}
height: paintedHeight
elide: Text.ElideRight
font.pointSize: theme.smallestFont.pointSize
text: details[(index*2)+1]
textFormat: Text.PlainText
MouseArea {
anchors.fill: parent
acceptedButtons: Qt.RightButton
onPressed: contextMenu.show(this, detailValueLabel.text, mouse.x, mouse.y)
}
anchors {
left: parent.left
right: parent.right
leftMargin: repeater.longestString + Math.round(units.gridUnit / 2)
}
height: paintedHeight
elide: Text.ElideRight
font.pointSize: theme.smallestFont.pointSize
text: details[(index*2)+1]
textFormat: Text.PlainText
MouseArea {
anchors.fill: parent
acceptedButtons: Qt.RightButton
onPressed: contextMenu.show(this, detailValueLabel.text, mouse.x, mouse.y)
}
}
// Count total height from added items, somehow contentRect.height doesn't work
onItemAdded: {
contentHeight = contentHeight + item.height
}
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment