FullRepresentation.qml 2.7 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
/*
 *   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

Faces.SensorFace {
    id: root
    readonly property bool showLegend: controller.faceConfiguration.showLegend
    // 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
37
    Layout.preferredWidth: titleMetrics.width
Marco Martin's avatar
Marco Martin committed
38
39
40

    contentItem: ColumnLayout {
        Kirigami.Heading {
Marco Martin's avatar
Marco Martin committed
41
            id: heading
Marco Martin's avatar
Marco Martin committed
42
43
44
45
46
47
            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
48
49
50
51
52
            TextMetrics {
                id: titleMetrics
                font: heading.font
                text: heading.text
            }
Marco Martin's avatar
Marco Martin committed
53
54
55
56
57
58
59
60
61
62
63
64
65
66
        }

        LineChart {
            id: compactRepresentation
            Layout.fillWidth: true
            Layout.fillHeight: true
            Layout.minimumHeight: 3 * Kirigami.Units.gridUnit
            Layout.preferredHeight: 5 * Kirigami.Units.gridUnit
        }

        Faces.ExtendedLegend {
            Layout.fillWidth: root.width < implicitWidth * 1.5
            Layout.alignment: Qt.AlignVCenter | Qt.AlignLeft
            Layout.fillHeight: true
Marco Martin's avatar
Marco Martin committed
67
            Layout.minimumHeight: root.formFactor !== Faces.SensorFace.Planar ? implicitHeight : -1
Marco Martin's avatar
Marco Martin committed
68
69
70
71
72
73
74
75
            visible: root.showLegend
            chart: compactRepresentation
            sourceModel: root.showLegend ? compactRepresentation.sensorsModel : null
            colorSource: root.colorSource
            sensorIds: root.showLegend ? root.controller.lowPrioritySensorIds : []
        }
    }
}