summaryrefslogtreecommitdiffstats
path: root/examples/applicationmanager/process-status/system-ui/CpuGraph.qml
blob: ea4960c30925ff9f69ac923e353de0d04c16fa54 (plain)
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// Copyright (C) 2021 The Qt Company Ltd.
// Copyright (C) 2019 Luxoft Sweden AB
// Copyright (C) 2018 Pelagicore AG
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause

pragma ComponentBehavior: Bound

import QtQuick
import QtQuick.Controls
import QtApplicationManager
import QtApplicationManager.SystemUI

/*
    This file shows how to use ProcessStatus inside a MonitorModel to draw a graph
 */
Pane {
    id: root

    property var application

    ListView {
        id: listView
        anchors.fill: parent
        orientation: ListView.Horizontal
        spacing: (root.width / model.count) * 0.2
        clip: true
        interactive: false

        model: MonitorModel {
            id: monitorModel
            running: root.visible && root.application.runState === Am.Running
            ProcessStatus {
                applicationId: root.application.id
            }
        }

        delegate: Rectangle {
            required property var model
            width: (root.width / monitorModel.count) * 0.8
            height: model.cpuLoad * root.height
            y: root.height - height
            color: root.palette.highlight
        }
    }

    Label {
        anchors.top: parent.top
        text: "100%"
        font.pixelSize: 15
    }

    Label {
        anchors.verticalCenter: parent.verticalCenter
        text: "50%"
        font.pixelSize: 15
    }

    Label {
        anchors.bottom: parent.bottom
        text: "0%"
        font.pixelSize: 15
    }
}