FullRepresentation.qml 2.79 KB
Newer Older
Marco Martin's avatar
Marco Martin committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/*
 *   Copyright 2019 Marco Martin <mart@kde.org>
 *   Copyright 2019 David Edmundson <davidedmundson@kde.org>
 *   Copyright 2019 Arjen Hiemstra <ahiemstra@heimr.nl>
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU Library General Public License as
 *   published by the Free Software Foundation; either version 2, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details
 *
 *   You should have received a copy of the GNU Library General Public
 *   License along with this program; if not, write to the
 *   Free Software Foundation, Inc.,
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */

import QtQuick 2.9
import QtQuick.Layouts 1.1

import org.kde.kirigami 2.8 as Kirigami

import org.kde.ksysguard.sensors 1.0 as Sensors
import org.kde.ksysguard.faces 1.0 as Faces

import org.kde.quickcharts 1.0 as Charts
import org.kde.quickcharts.controls 1.0 as ChartsControls

Faces.SensorFace {
    id: root

    // Arbitrary minimumWidth to make easier to align plasmoids in a predictable way
    Layout.minimumWidth: Kirigami.Units.gridUnit * 8
Marco Martin's avatar
Marco Martin committed
38
    Layout.preferredWidth: titleMetrics.width
Marco Martin's avatar
Marco Martin committed
39
40
41
42

    contentItem: ColumnLayout {

        Kirigami.Heading {
Marco Martin's avatar
Marco Martin committed
43
            id: heading
Marco Martin's avatar
Marco Martin committed
44
45
46
47
48
49
            Layout.fillWidth: true
            horizontalAlignment: Text.AlignHCenter
            elide: Text.ElideRight
            text: root.controller.title
            visible: text.length > 0
            level: 2
Marco Martin's avatar
Marco Martin committed
50
51
52
53
54
            TextMetrics {
                id: titleMetrics
                font: heading.font
                text: heading.text
            }
Marco Martin's avatar
Marco Martin committed
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
        }

        Item { Layout.fillWidth: true; Layout.fillHeight: true }

        Repeater {
            model: root.controller.highPrioritySensorIds.concat(root.controller.lowPrioritySensorIds)

            ChartsControls.LegendDelegate {
                readonly property bool isTextOnly: index >= root.controller.highPrioritySensorIds.length

                Layout.fillWidth: true
                Layout.minimumHeight: isTextOnly ? 0 : implicitHeight

                name: sensor.shortName
                value: sensor.formattedValue
                colorVisible: !isTextOnly
Marco Martin's avatar
Marco Martin committed
71
                color: !isTextOnly ? root.colorSource.map[modelData] : "transparent"
Marco Martin's avatar
Marco Martin committed
72
73
74
75
76
77
78
79
80
81
82
83
84
85

                layoutWidth: root.width
                valueWidth: Kirigami.Units.gridUnit * 2

                Sensors.Sensor {
                    id: sensor
                    sensorId: modelData
                }
            }
        }

        Item { Layout.fillWidth: true; Layout.fillHeight: true }
    }
}