Debian Codegraph @

src/qml/InfoPane.qml

raw
1 // SPDX-License-Identifier: GPL-3.0-or-later
2 // Copyright 2019 Juan Palacios <[email protected]>
3
4 import QtQuick 2.15
5 import QtQuick.Controls 2.15
6 import QtQuick.Layouts 1.15
7 import "Style.js" as Style
8
9 Pane {
10
11 width: parent.width
12 height: parent.height
13
14 padding: 2
15
16 function addInfo(infoPairArray) {
17 for (var i = 0; i < infoPairArray.length; i+=2) {
18 infoModel.append({ "_title": infoPairArray[i],
19 "_text": infoPairArray[i + 1]})
20 }
21 }
22
23 ListModel {
24 id: infoModel
25 }
26
27 Component {
28 id: infoUnit
29
30 Pane {
31 implicitWidth: 237
32 implicitHeight: 60
33
34 padding: Style.RectItem.padding
35
36 background: Rectangle {
37 color: hovered ? Style.RectItem.background_hover
38 : Style.RectItem.background
39 }
40
41 ToolTip.delay: Style.ToolTip.delay
42 ToolTip.timeout: Style.ToolTip.timeout
43 ToolTip.visible: hovered
44 ToolTip.text: title.text + ": " + info.text
45
46 ColumnLayout {
47 spacing: 4
48 anchors.fill: parent
49
50 Label {
51 id: title
52 text: _title
53 elide: Text.ElideRight
54 color: Style.RectItem.text_color
55 Layout.fillWidth: true
56 }
57
58 Label {
59 id: info
60 text: _text
61 elide: Text.ElideRight
62 color: Style.RectItem.text_color_alt
63 Layout.fillWidth: true
64 }
65 }
66 }
67 }
68
69 ScrollView {
70 id: scrollview
71 anchors.fill: parent
72 clip: true
73 ScrollBar.horizontal.policy: ScrollBar.AlwaysOn
74 ScrollBar.vertical.policy: ScrollBar.AlwaysOn
75 ScrollBar.horizontal.visible: ScrollBar.horizontal.size < 1
76 ScrollBar.vertical.visible: ScrollBar.vertical.size < 1
77
78 Flow {
79 id: flow
80 width: scrollview.availableWidth
81 height: scrollview.availableHeight
82 spacing: Style.RectItemList.spacing
83
84 Repeater {
85 model: infoModel
86 delegate: infoUnit
87 }
88
89 move: Transition {
90 NumberAnimation { properties: "x,y"; easing.type: Easing.InOutQuad }
91 }
92 }
93 }
94 }