-
Notifications
You must be signed in to change notification settings - Fork 1
/
WidgetContainer.h
74 lines (62 loc) · 1.89 KB
/
WidgetContainer.h
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
#ifndef WIDGETCONTAINER_H
#define WIDGETCONTAINER_H
#include <boost/shared_ptr.hpp>
#include <QtWidgets/QLabel>
#include <QFont>
#include <iostream>
#include "NTreeReader.h"
#include "ProcessHelper.h"
using std::cout;
using std::endl;
/* A couple of quick reminders:
/proc/stat - CPU stats
/proc/net/dev - Network stats
*/
class WidgetContainer
{
public:
QLabel* label;
QString format;
enum Type{Text, Image, Graph};
Type type;
enum Orientation{Vertical, Horizontal};
Orientation orientation;
long interval;
long remaining;
bool controlmaster;
QString host;
QString username;
QString idfile;
QString temppath;
WidgetContainer(QLabel*);
WidgetContainer();
// By default a no-op so this can be used directly for static widgets
virtual void Update() {}
virtual void SetText(QString);
virtual void ProcessFinished(QString) {}
static unsigned long KB() {return KBv;}
static unsigned long MB() {return MBv;}
static unsigned long GB() {return GBv;}
static unsigned long TB() {return TBv;}
static unsigned long PB() {return PBv;}
static unsigned long EB() {return EBv;}
static unsigned long ZB() {return ZBv;}
static unsigned long YB() {return YBv;}
protected:
static unsigned long KBv, MBv, GBv, TBv, PBv, EBv, ZBv, YBv;
QFont font;
float lastpercent;
// This object is no longer safe to copy once this has been initialized!
ProcessHelperPtr helper;
void SetLabelMask(float);
void DrawGraph(float);
string GetFile(QString, bool startprocess = true);
void InitProcessHelper();
};
typedef boost::shared_ptr<WidgetContainer> WidgetContainerPtr;
template <typename t>
t clamp(t val, t min, t max)
{
return val < min ? min : (val > max ? max : val);
}
#endif // WIDGETCONTAINER_H