forked from KDE/liquidshell
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSysLoad.hxx
98 lines (75 loc) · 2.56 KB
/
SysLoad.hxx
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/*
Copyright 2017 Martin Koller, [email protected]
This file is part of liquidshell.
liquidshell is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
liquidshell 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 General Public License
along with liquidshell. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _SysLoad_H_
#define _SysLoad_H_
#include <QFrame>
#include <QVector>
#include <QMap>
#include <QByteArray>
#include <QTimer>
class SysLoad : public QFrame
{
Q_OBJECT
Q_PROPERTY(QColor cpuUserColor MEMBER cpuUserColor)
Q_PROPERTY(QColor cpuSystemColor MEMBER cpuSystemColor)
Q_PROPERTY(QColor cpuNiceColor MEMBER cpuNiceColor)
Q_PROPERTY(bool cpuSummaryBar MEMBER cpuSummaryBar)
Q_PROPERTY(QColor memUsedColor MEMBER memUsedColor)
Q_PROPERTY(QColor memCachedColor MEMBER memCachedColor)
Q_PROPERTY(QColor memSwapColor MEMBER memSwapColor)
Q_PROPERTY(QColor netReceivedColor MEMBER netReceivedColor)
Q_PROPERTY(QColor netSentColor MEMBER netSentColor)
public:
SysLoad(QWidget *parent);
protected:
void paintEvent(QPaintEvent *event) override;
void mousePressEvent(QMouseEvent *event) override;
private Q_SLOTS:
void fetch();
private:
struct CpuData
{
int userCPU = 0, niceCPU = 0, systemCPU = 0;
double userPercent = 0, nicePercent = 0, systemPercent = 0;
double MHz = 0;
};
struct MemoryData
{
double memPercent = 0;
double memCachedPercent = 0;
double swapPercent = 0;
} memData;
struct NetworkData
{
size_t prevReceived = 0, prevSent = 0;
size_t received = 0, sent = 0;
bool valid = false;
};
QVector<CpuData> cpus;
QMap<QByteArray, NetworkData> netDevs;
size_t maxBytes = 100;
size_t sumSent = 0, sumReceived = 0;
QTimer timeoutTimer;
QColor cpuUserColor = "#881f1f";
QColor cpuSystemColor = Qt::darkGreen;
QColor cpuNiceColor = Qt::yellow;
bool cpuSummaryBar = false;
QColor memUsedColor = Qt::blue;
QColor memCachedColor = Qt::darkGreen;
QColor memSwapColor = Qt::cyan;
QColor netReceivedColor = Qt::green;
QColor netSentColor = Qt::red;
};
#endif