b85726132
김태훈
부가 기능 UI 추가
|
1
2
|
#include "cookpanelbutton.h"
#include "ui_cookpanelbutton.h"
|
9e1f8d093
김태훈
엔코더 구현 대비 선행 수정
|
3
|
#include <QKeyEvent>
|
bbd7d8f29
김태훈
버튼 음향 추가
|
4
|
#include "soundplayer.h"
|
f588aa273
김태훈
부가 기능 로직 추가
|
5
6
7
|
#include "manualcooksettingwidget.h"
CookPanelButton::CookPanelButton(CookRecord record, QWidget *parent) :
|
b85726132
김태훈
부가 기능 UI 추가
|
8
|
QWidget(parent),
|
f588aa273
김태훈
부가 기능 로직 추가
|
9
10
|
record(record),
ui(new Ui::CookPanelButton),
|
382b586e9
김태훈
프로그래밍 모드 임시 구현
|
11
12
|
rendered(false),
longPressEnabled(false)
|
b85726132
김태훈
부가 기능 UI 추가
|
13
14
|
{
ui->setupUi(this);
|
f588aa273
김태훈
부가 기능 로직 추가
|
15
16
|
setText(record.name);
|
bbd7d8f29
김태훈
버튼 음향 추가
|
17
18
19
|
foreach (QPushButton *button, findChildren<QPushButton *>())
connect(button, &QPushButton::pressed, SoundPlayer::playClick);
|
382b586e9
김태훈
프로그래밍 모드 임시 구현
|
20
21
|
longPressedTimer.setSingleShot(true);
|
5228da630
김태훈
딜레이 변경
|
22
|
longPressedTimer.setInterval(3000);
|
382b586e9
김태훈
프로그래밍 모드 임시 구현
|
23
|
connect(&longPressedTimer, SIGNAL(timeout()), SLOT(emitLongPressed()));
|
b85726132
김태훈
부가 기능 UI 추가
|
24
25
26
27
28
29
30
31
32
33
34
|
}
CookPanelButton::~CookPanelButton()
{
delete ui;
}
void CookPanelButton::setText(QString text)
{
ui->pushButton->setText(text);
}
|
f588aa273
김태훈
부가 기능 로직 추가
|
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
|
void CookPanelButton::showInfo()
{
if (!rendered)
{
QPixmap p = CookHistory::render(record);
label = new QLabel(this);
label->setPixmap(p);
label->setGeometry((width() - p.width()) / 2, 65, p.width(), p.height());
}
label->show();
setMinimumHeight(ui->pushButton->height() + label->height());
}
void CookPanelButton::hideInfo()
{
label->hide();
setMinimumHeight(ui->pushButton->height());
}
void CookPanelButton::focusBar()
{
ui->pushButton->setFocus();
}
void CookPanelButton::focusInfoButton()
{
ui->showInfoButton->setFocus();
}
void CookPanelButton::focusDeleteButton()
{
ui->deleteButton->setFocus();
}
|
382b586e9
김태훈
프로그래밍 모드 임시 구현
|
71
72
73
74
|
void CookPanelButton::setLongPressEnabled(bool enabled)
{
longPressEnabled = enabled;
}
|
964071391
김태훈
길게 눌러 팝업이 뜬 상태로 다...
|
75
76
77
78
79
80
|
void CookPanelButton::setEnabled(bool enabled)
{
ui->pushButton->setEnabled(enabled);
ui->showInfoButton->setEnabled(enabled);
ui->deleteButton->setEnabled(enabled);
}
|
9e1f8d093
김태훈
엔코더 구현 대비 선행 수정
|
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
|
void CookPanelButton::keyPressEvent(QKeyEvent *event)
{
switch (event->key())
{
case 0x01000030: // Turn left
onEncoderLeft();
break;
case 0x01000031: // Push
pushed = focusWidget();
break;
case 0x01000032: // Turn right
onEncoderRight();
break;
}
}
void CookPanelButton::keyReleaseEvent(QKeyEvent *event)
{
switch (event->key())
{
case 0x01000030: // Turn left
onEncoderLeft();
break;
case 0x01000031: // Push
if (focusWidget() == pushed)
onEncoderClicked(pushed);
pushed = NULL;
break;
case 0x01000032: // Turn right
onEncoderRight();
break;
}
}
|
382b586e9
김태훈
프로그래밍 모드 임시 구현
|
115
116
117
118
119
|
void CookPanelButton::emitLongPressed()
{
emitted = true;
emit longPressed(this);
}
|
f588aa273
김태훈
부가 기능 로직 추가
|
120
|
|
382b586e9
김태훈
프로그래밍 모드 임시 구현
|
121
|
void CookPanelButton::on_showInfoButton_clicked()
|
f588aa273
김태훈
부가 기능 로직 추가
|
122
123
124
125
126
127
|
{
emit infoClicked(this);
}
void CookPanelButton::on_pushButton_clicked()
{
|
382b586e9
김태훈
프로그래밍 모드 임시 구현
|
128
129
|
if (longPressEnabled && emitted)
return;
|
f588aa273
김태훈
부가 기능 로직 추가
|
130
131
132
133
134
135
136
|
CookHistory::start(record, parentWidget());
}
void CookPanelButton::on_deleteButton_clicked()
{
emit deleteClicked(this);
}
|
382b586e9
김태훈
프로그래밍 모드 임시 구현
|
137
|
|
9e1f8d093
김태훈
엔코더 구현 대비 선행 수정
|
138
139
140
141
142
143
144
145
146
147
148
149
150
151
|
void CookPanelButton::onEncoderLeft()
{
}
void CookPanelButton::onEncoderRight()
{
}
void CookPanelButton::onEncoderClicked(QWidget *clicked)
{
}
|
382b586e9
김태훈
프로그래밍 모드 임시 구현
|
152
153
154
155
156
157
158
159
160
161
|
void CookPanelButton::on_pushButton_pressed()
{
longPressedTimer.start();
emitted = false;
}
void CookPanelButton::on_pushButton_released()
{
longPressedTimer.stop();
}
|