Changeset View
Changeset View
Standalone View
Standalone View
applet/contents/ui/DetailsText.qml
Show All 19 Lines | |||||
20 | 20 | | |||
21 | import QtQuick 2.2 | 21 | import QtQuick 2.2 | ||
22 | import org.kde.kquickcontrolsaddons 2.0 as KQuickControlsAddons | 22 | import org.kde.kquickcontrolsaddons 2.0 as KQuickControlsAddons | ||
23 | import org.kde.plasma.components 2.0 as PlasmaComponents | 23 | import org.kde.plasma.components 2.0 as PlasmaComponents | ||
24 | 24 | | |||
25 | Item { | 25 | Item { | ||
26 | property var details: [] | 26 | property var details: [] | ||
27 | 27 | | |||
28 | height: repeater.contentHeight | 28 | height: childrenRect.height | ||
29 | 29 | | |||
30 | KQuickControlsAddons.Clipboard { | 30 | KQuickControlsAddons.Clipboard { | ||
31 | id: clipboard | 31 | id: clipboard | ||
32 | } | 32 | } | ||
33 | 33 | | |||
34 | PlasmaComponents.ContextMenu { | 34 | PlasmaComponents.ContextMenu { | ||
35 | id: contextMenu | 35 | id: contextMenu | ||
36 | property string text | 36 | property string text | ||
37 | 37 | | |||
38 | function show(item, text, x, y) { | 38 | function show(item, text, x, y) { | ||
39 | contextMenu.text = text | 39 | contextMenu.text = text | ||
40 | visualParent = item | 40 | visualParent = item | ||
41 | open(x, y) | 41 | open(x, y) | ||
42 | } | 42 | } | ||
43 | 43 | | |||
44 | PlasmaComponents.MenuItem { | 44 | PlasmaComponents.MenuItem { | ||
45 | text: i18n("Copy") | 45 | text: i18n("Copy") | ||
46 | icon: "edit-copy" | 46 | icon: "edit-copy" | ||
47 | enabled: contextMenu.text !== "" | 47 | enabled: contextMenu.text !== "" | ||
48 | onClicked: clipboard.content = contextMenu.text | 48 | onClicked: clipboard.content = contextMenu.text | ||
49 | } | 49 | } | ||
50 | } | 50 | } | ||
51 | 51 | | |||
52 | Column { | 52 | Column { | ||
53 | anchors.fill: parent | 53 | anchors { | ||
54 | left: parent.left | ||||
55 | right: parent.right | ||||
56 | } | ||||
57 | height: childrenRect.height | ||||
54 | 58 | | |||
55 | Repeater { | 59 | Repeater { | ||
56 | id: repeater | 60 | id: repeater | ||
57 | 61 | | |||
58 | property int contentHeight: 0 | 62 | property int contentHeight: 0 | ||
59 | property int longestString: 0 | 63 | property int longestString: 0 | ||
60 | 64 | | |||
61 | model: details.length / 2 | 65 | model: details.length / 2 | ||
62 | 66 | | |||
63 | Item { | 67 | Item { | ||
64 | anchors { | 68 | anchors { | ||
65 | left: parent.left | 69 | left: parent.left | ||
66 | right: parent.right | 70 | right: parent.right | ||
67 | topMargin: Math.round(units.gridUnit / 3) | | |||
68 | } | 71 | } | ||
69 | height: Math.max(detailNameLabel.height, detailValueLabel.height) | 72 | height: Math.max(detailNameLabel.height, detailValueLabel.height) | ||
70 | 73 | | |||
71 | PlasmaComponents.Label { | 74 | PlasmaComponents.Label { | ||
72 | id: detailNameLabel | 75 | id: detailNameLabel | ||
73 | 76 | | |||
74 | anchors { | 77 | anchors { | ||
75 | left: parent.left | 78 | left: parent.left | ||
76 | leftMargin: repeater.longestString - paintedWidth + Math.round(units.gridUnit / 2) | 79 | leftMargin: repeater.longestString - paintedWidth + units.smallSpacing * 2 | ||
77 | verticalCenter: parent.verticalCenter | | |||
78 | } | 80 | } | ||
79 | height: paintedHeight | 81 | height: paintedHeight | ||
80 | font.pointSize: theme.smallestFont.pointSize | 82 | font.pointSize: theme.smallestFont.pointSize | ||
81 | horizontalAlignment: Text.AlignRight | 83 | horizontalAlignment: Text.AlignRight | ||
82 | text: details[index*2] + ": " | 84 | text: details[index*2] + ": " | ||
85 | opacity: 0.6 | ||||
83 | 86 | | |||
84 | Component.onCompleted: { | 87 | Component.onCompleted: { | ||
85 | if (paintedWidth > repeater.longestString) { | 88 | if (paintedWidth > repeater.longestString) { | ||
86 | repeater.longestString = paintedWidth | 89 | repeater.longestString = paintedWidth | ||
87 | } | 90 | } | ||
88 | } | 91 | } | ||
89 | } | 92 | } | ||
90 | 93 | | |||
91 | PlasmaComponents.Label { | 94 | PlasmaComponents.Label { | ||
92 | id: detailValueLabel | 95 | id: detailValueLabel | ||
93 | 96 | | |||
94 | anchors { | 97 | anchors { | ||
98 | // TODO Fix bind loop messages for width. | ||||
95 | left: detailNameLabel.right | 99 | left: detailNameLabel.right | ||
96 | right: parent.right | 100 | right: parent.right | ||
97 | verticalCenter: parent.verticalCenter | | |||
98 | } | 101 | } | ||
99 | height: paintedHeight | 102 | height: paintedHeight | ||
100 | elide: Text.ElideRight | 103 | elide: Text.ElideRight | ||
101 | font.pointSize: theme.smallestFont.pointSize | 104 | font.pointSize: theme.smallestFont.pointSize | ||
102 | text: details[(index*2)+1] | 105 | text: { // RESTORE before commit for final review | ||
106 | if (capturePublicScreenshot) { | ||||
107 | if (index === 0 || index === 4 ) { | ||||
108 | return "WIRELESS-123456" | ||||
109 | } else if (index === 3 || index === 8) { | ||||
110 | return "01:23:45:67:89:01" | ||||
111 | } | ||||
112 | } | ||||
113 | return details[(index*2)+1] | ||||
114 | } | ||||
103 | textFormat: Text.PlainText | 115 | textFormat: Text.PlainText | ||
104 | 116 | | |||
105 | MouseArea { | 117 | MouseArea { | ||
106 | anchors.fill: parent | 118 | anchors.fill: parent | ||
107 | acceptedButtons: Qt.RightButton | 119 | acceptedButtons: Qt.RightButton | ||
108 | onPressed: contextMenu.show(this, detailValueLabel.text, mouse.x, mouse.y) | 120 | onPressed: contextMenu.show(this, detailValueLabel.text, mouse.x, mouse.y) | ||
109 | } | 121 | } | ||
110 | } | 122 | } | ||
111 | } | 123 | } | ||
112 | | ||||
113 | // Count total height from added items, somehow contentRect.height doesn't work | | |||
114 | onItemAdded: { | | |||
115 | contentHeight = contentHeight + item.height | | |||
116 | } | | |||
117 | } | 124 | } | ||
118 | } | 125 | } | ||
119 | } | 126 | } |