summaryrefslogtreecommitdiff
path: root/src/shared-main-lib/cpustatus.h
blob: 416440290e5e4ee78f82eba1e77639811cb9bcfd (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
// 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 GPL-3.0-only

#pragma once

#include <QtAppManCommon/global.h>

#include <QtAppManMonitor/systemreader.h>

#include <QObject>
#include <QScopedPointer>

QT_BEGIN_NAMESPACE_AM

class CpuStatus : public QObject
{
    Q_OBJECT
    Q_CLASSINFO("AM-QmlType", "QtApplicationManager/CpuStatus 2.0")
    Q_PROPERTY(qreal cpuLoad READ cpuLoad NOTIFY cpuLoadChanged)
    Q_PROPERTY(int cpuCores READ cpuCores CONSTANT)

    Q_PROPERTY(QStringList roleNames READ roleNames CONSTANT)

public:
    CpuStatus(QObject *parent = nullptr);

    qreal cpuLoad() const;
    int cpuCores() const;

    QStringList roleNames() const;

    Q_INVOKABLE void update();

signals:
    void cpuLoadChanged();

private:
    QScopedPointer<CpuReader> m_cpuReader;
    qreal m_cpuLoad;
};

QT_END_NAMESPACE_AM