This repository was archived by the owner on Apr 12, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathappliancewidget.cpp
More file actions
108 lines (102 loc) · 2.38 KB
/
appliancewidget.cpp
File metadata and controls
108 lines (102 loc) · 2.38 KB
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
99
100
101
102
103
104
105
106
107
108
#include "appliancewidget.h"
#include "ui_appliancewidget.h"
#include <QLabel>
#include <QPixmap>
ApplianceWidget::ApplianceWidget(QWidget *parent, Appliance* a) :
QWidget(parent),
ui(new Ui::ApplianceWidget)
{
ui->setupUi(this);
appliance = a;
switch (appliance->getType()) {
case TYPE_FRIDGE:
{
bg = "#0099ff";
QPixmap ico(":/icons/jaakaappi.png");
ui->icon->setPixmap(ico);
break;
}
case TYPE_BLENDER:
{
bg = "#ff9900";
QPixmap ico(":/icons/tehosekotin.png");
ui->icon->setPixmap(ico);
break;
}
case TYPE_HEATING:
{
bg = "#ff0000";
QPixmap ico(":/icons/sahkolammitys.png");
ui->icon->setPixmap(ico);
break;
}
case TYPE_SAUNA:
{
bg = "#aaaaaa";
QPixmap ico(":/icons/kiuas.png");
ui->icon->setPixmap(ico);
break;
}
case TYPE_WASH:
{
bg = "#0000aa";
QPixmap ico(":/icons/pesukone.png");
ui->icon->setPixmap(ico);
break;
}
case TYPE_DISH:
{
bg = "#0000ff";
QPixmap ico(":/icons/jaakaappi.png");
ui->icon->setPixmap(ico);
break;
}
case TYPE_TV:
{
bg = "#ff6666";
QPixmap ico(":/icons/tv.png");
ui->icon->setPixmap(ico);
break;
}
case TYPE_PC:
{
bg = "#777777";
QPixmap ico(":/icons/tietokone.png");
ui->icon->setPixmap(ico);
break;
}
case TYPE_LIGHT:
{
bg = "#ffff00";
QPixmap ico(":/icons/valo.png");
ui->icon->setPixmap(ico);
break;
}
default:
break;
}
}
ApplianceWidget::~ApplianceWidget()
{
delete ui;
}
void ApplianceWidget::tick(int t)
{
if(appliance->getPowerState() == POWER_FORCED_ON || appliance->getPowerState() == POWER_GRANTED_ON)
{
ui->power->setText(QString::number(appliance->getPower()) + " W");
this->setStyleSheet("* { background-color : " + bg + "; }");
}
else
{
ui->power->setText(QString::number(0) + " W");
this->setStyleSheet("* { background-color : transparent; }");
}
if(appliance->getPowerState() == POWER_QUEUED)
{
if(t % 20 < 10)
this->setStyleSheet("* { background-color : " + bg + "; }");
else
this->setStyleSheet("* { background-color : transparent; }");
}
}