-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTemperatureWidget.cpp
46 lines (40 loc) · 953 Bytes
/
TemperatureWidget.cpp
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
#include "TemperatureWidget.h"
#include <iostream>
using std::cout;
using std::endl;
TemperatureWidget::TemperatureWidget(QLabel* l)
{
label = l;
}
void TemperatureWidget::Update()
{
InitProcessHelper();
if (helper->Active())
return;
QString remote = "";
if (host != "localhost")
remote = "ssh " + host + " ";
QString qcommand = remote + "sensors " + QString(chip.c_str()) + " | grep '" + QString(tempid.c_str()) + "' | perl -pe 's/(.*?\\+)([0-9]*)(.*)/\\2/'";
helper->Start(qcommand, this);
}
void TemperatureWidget::ProcessFinished(QString text)
{
float temp = text.toFloat();
if (type == Text)
{
QString value = format;
QString stemp;
stemp.setNum(temp);
value.replace("%s", stemp);
SetText(value);
}
else if (type == Image)
{
SetLabelMask(float(temp) / max);
}
else if (type == Graph)
{
DrawGraph(float(temp) / max);
}
text = "";
}