operationtimeparts.cpp
3.9 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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#include <QKeyEvent>
#include <qdebug.h>
#include "operationtimeparts.h"
#include "ui_operationtimeparts.h"
#include "ovenstatics.h"
#include "soundplayer.h"
OperationTimeParts::OperationTimeParts(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::OperationTimeParts)
{
int i=0;
OvenStatistics* ovs = OvenStatistics::getInstance();
ui->setupUi(this);
ui->clockContainer->setParent(ui->upperStack);
setAttribute(Qt::WA_DeleteOnClose);
foreach (QPushButton *button, findChildren<QPushButton *>())
connect(button, &QPushButton::pressed, SoundPlayer::playClick);
m_arrTimeLabels[0] = ui->m_ctrlLbListTime_1;
m_arrTimeLabels[1] = ui->m_ctrlLbListTime_2;
m_arrTimeLabels[2] = ui->m_ctrlLbListTime_3;
m_arrTimeLabels[3] = ui->m_ctrlLbListTime_4;
m_arrTimeLabels[4] = ui->m_ctrlLbListTime_5;
m_arrTimeLabels[5] = ui->m_ctrlLbListTime_6;
m_arrTimeLabels[6] = ui->m_ctrlLbListTime_7;
m_arrTimeLabels[7] = ui->m_ctrlLbListTime_8;
m_arrTimeLabels[8] = ui->m_ctrlLbListTime_9;
m_arrTimeLabels[9] = ui->m_ctrlLbListTime_10;
m_arrTimeLabels[10] = ui->m_ctrlLbListTime_11;
m_arrResetBtn[0] = ui->btnReset_1;
m_arrResetBtn[1] = ui->btnReset_2;
m_arrResetBtn[2] = ui->btnReset_3;
m_arrResetBtn[3] = ui->btnReset_4;
m_arrResetBtn[4] = ui->btnReset_5;
m_arrResetBtn[5] = ui->btnReset_6;
m_arrResetBtn[6] = ui->btnReset_7;
m_arrResetBtn[7] = ui->btnReset_8;
m_arrResetBtn[8] = ui->btnReset_9;
m_arrResetBtn[9] = ui->btnReset_10;
m_arrResetBtn[10] = ui->btnReset_11;
m_btnGrops = new QButtonGroup();
for(i=0;i<OPERATION_TIME_CONTROL_MAX;i++){
m_btnGrops->addButton(m_arrResetBtn[i],i);
}
connect(m_btnGrops,SIGNAL(buttonClicked(int)),this,SLOT(on_btnResets_clicked(int)));
if(ovs != NULL){
for( i =0;i<OPERATION_TIME_PARTS_MAX_ITEM;i++){
if(m_arrPartItemIdxs[i] != 0xffff){
m_arrUseItems[i] = &(ovs->srvdata->use_log.values[m_arrPartItemIdxs[i]]);
}
else m_arrUseItems[i] = NULL;
}
}
reloadUi();
}
OperationTimeParts::~OperationTimeParts()
{
delete ui;
}
void OperationTimeParts::on_backButton_clicked()
{
close();
}
void OperationTimeParts::reloadUi(void){
uint32_t timetemp;
OvenStatistics* ovs = OvenStatistics::getInstance();
QString strTemp="";
int i = 0;
if(ovs != NULL){
for(i = 0; i<OPERATION_TIME_PARTS_MAX_ITEM;i++){
if(m_arrUseItems[i] != NULL){
timetemp = *m_arrUseItems[i];
strTemp.sprintf("%d min", timetemp/60);
m_arrTimeLabels[i]->setText(strTemp);
}
else{
m_arrTimeLabels[i]->setText("-");
}
}
}
else{
for(i=0;i<OPERATION_TIME_PARTS_MAX_ITEM;i++){
m_arrTimeLabels[i]->setText("-");
}
}
}
void OperationTimeParts::on_btnReset_2_clicked()
{
}
void OperationTimeParts::on_btnResets_clicked(int idx){
qDebug() << "PUSH BUTTON " << idx;
if(idx < OPERATION_TIME_CONTROL_MAX){
if(m_arrUseItems[idx] !=NULL){
*m_arrUseItems[idx]=0;
reloadUi();
}
}
}
void OperationTimeParts::keyPressEvent(QKeyEvent *event)
{
switch (event->key())
{
case 0x01000030: // Turn left
focusPreviousChild();
break;
case 0x01000031: // Push
break;
case 0x01000032: // Turn right
focusNextChild();
break;
}
}
void OperationTimeParts::keyReleaseEvent(QKeyEvent *event)
{
switch (event->key())
{
case 0x01000030: // Turn left
focusPreviousChild();
break;
case 0x01000031: // Push
{
QPushButton *btn = qobject_cast<QPushButton*>(focusWidget());
if(btn != NULL){
btn->click();
}
break;
}
case 0x01000032: // Turn right
focusNextChild();
break;
}
}