b85726132
김태훈
부가 기능 UI 추가
|
1
2
|
#include "primewindow.h"
#include "ui_primewindow.h"
|
f588aa273
김태훈
부가 기능 로직 추가
|
3
4
5
|
#include <QtDebug>
#include <QLabel>
#include <QPainter>
|
9e1f8d093
김태훈
엔코더 구현 대비 선행 수정
|
6
|
#include <QKeyEvent>
|
f588aa273
김태훈
부가 기능 로직 추가
|
7
8
9
|
#include "manualcooksettingwidget.h"
#include "cookhistory.h"
|
bbd7d8f29
김태훈
버튼 음향 추가
|
10
|
#include "soundplayer.h"
|
e00c6a2a9
김태훈
기능 추가 구현
|
11
12
13
|
#include "configwindow.h"
#include "washwindow.h"
#include "mainwindow.h"
|
b85726132
김태훈
부가 기능 UI 추가
|
14
15
16
17
18
19
20
21
22
23
24
|
PrimeWindow::PrimeWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::PrimeWindow)
{
ui->setupUi(this);
ui->clockContainer->setParent(ui->upperStack);
setAttribute(Qt::WA_DeleteOnClose);
ui->verticalScrollLayout->setAlignment(Qt::AlignTop);
|
f588aa273
김태훈
부가 기능 로직 추가
|
25
26
|
lastInfoDisplayed = NULL;
|
bbd7d8f29
김태훈
버튼 음향 추가
|
27
28
29
|
foreach (QPushButton *button, findChildren<QPushButton *>())
connect(button, &QPushButton::pressed, SoundPlayer::playClick);
|
b85726132
김태훈
부가 기능 UI 추가
|
30
31
32
33
34
35
|
}
PrimeWindow::~PrimeWindow()
{
delete ui;
}
|
f588aa273
김태훈
부가 기능 로직 추가
|
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
|
void PrimeWindow::listMostCooked()
{
if (!ui->mostCookedButton->isChecked())
{
ui->mostCookedButton->blockSignals(true);
ui->mostCookedButton->setChecked(true);
ui->mostCookedButton->blockSignals(false);
}
listButtons(CookHistory::listMostCooked());
}
void PrimeWindow::listRecents()
{
if (!ui->recentsButton->isChecked())
{
ui->recentsButton->blockSignals(true);
ui->recentsButton->setChecked(true);
ui->recentsButton->blockSignals(false);
}
listButtons(CookHistory::listRecents());
}
void PrimeWindow::listFavorites()
{
if (!ui->favoritesButton->isChecked())
{
ui->favoritesButton->blockSignals(true);
ui->favoritesButton->setChecked(true);
ui->favoritesButton->blockSignals(false);
}
listButtons(CookHistory::listFavorites());
}
void PrimeWindow::focusFavorite(int id)
{
foreach (CookPanelButton *b, list)
{
|
f588aa273
김태훈
부가 기능 로직 추가
|
76
77
|
if (b->record.id == id)
{
|
f588aa273
김태훈
부가 기능 로직 추가
|
78
79
80
81
82
|
b->focusBar();
break;
}
}
}
|
9e1f8d093
김태훈
엔코더 구현 대비 선행 수정
|
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
|
void PrimeWindow::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 PrimeWindow::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;
}
}
|
f588aa273
김태훈
부가 기능 로직 추가
|
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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
|
void PrimeWindow::on_mostCookedButton_toggled(bool checked)
{
if (!checked)
return;
listButtons(CookHistory::listMostCooked());
}
void PrimeWindow::on_recentsButton_toggled(bool checked)
{
if (!checked)
return;
listButtons(CookHistory::listRecents());
}
void PrimeWindow::on_favoritesButton_toggled(bool checked)
{
if (!checked)
return;
listButtons(CookHistory::listFavorites());
}
void PrimeWindow::listButtons(QList<CookRecord> records)
{
clear();
foreach(CookRecord r, records)
newButton(r);
ui->scrollAreaWidgetContents->adjustSize();
}
void PrimeWindow::clear()
{
lastInfoDisplayed = NULL;
while (!list.isEmpty())
list.takeFirst()->deleteLater();
}
CookPanelButton *PrimeWindow::newButton(CookRecord record)
{
CookPanelButton *button = new CookPanelButton(record, this);
connect(button, SIGNAL(infoClicked(CookPanelButton*)), SLOT(onInfoButtonClicked(CookPanelButton*)));
connect(button, SIGNAL(deleteClicked(CookPanelButton*)), SLOT(onDeleteButtonClicked(CookPanelButton*)));
ui->verticalScrollLayout->addWidget(button);
list.append(button);
return button;
}
void PrimeWindow::onInfoButtonClicked(CookPanelButton *panelButton)
{
if (lastInfoDisplayed)
{
if (panelButton == lastInfoDisplayed)
{
lastInfoDisplayed->hideInfo();
lastInfoDisplayed = NULL;
ui->scrollAreaWidgetContents->adjustSize();
}
else
{
lastInfoDisplayed->hideInfo();
lastInfoDisplayed = panelButton;
lastInfoDisplayed->showInfo();
ui->scrollAreaWidgetContents->adjustSize();
ui->scrollArea->ensureWidgetVisible(lastInfoDisplayed);
}
}
else
{
lastInfoDisplayed = panelButton;
lastInfoDisplayed->showInfo();
ui->scrollAreaWidgetContents->adjustSize();
ui->scrollArea->ensureWidgetVisible(lastInfoDisplayed);
}
}
void PrimeWindow::onDeleteButtonClicked(CookPanelButton *panelButton)
{
if (panelButton == lastInfoDisplayed)
lastInfoDisplayed = NULL;
if (ui->mostCookedButton->isChecked())
CookHistory::removeMostCooked(panelButton->record);
else if (ui->recentsButton->isChecked())
CookHistory::removeRecent(panelButton->record);
else if (ui->favoritesButton->isChecked())
CookHistory::removeFavorite(panelButton->record);
list.removeAll(panelButton);
panelButton->deleteLater();
}
|
b85726132
김태훈
부가 기능 UI 추가
|
216
217
218
219
|
void PrimeWindow::on_backButton_clicked()
{
close();
}
|
e00c6a2a9
김태훈
기능 추가 구현
|
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
|
void PrimeWindow::on_configButton_clicked()
{
ConfigWindow *w = new ConfigWindow(MainWindow::getInstance());
w->setWindowModality(Qt::WindowModal);
w->showFullScreen();
w->raise();
MainWindow::jump(w);
}
void PrimeWindow::on_washButton_clicked()
{
WashWindow *w = new WashWindow(MainWindow::getInstance());
w->setWindowModality(Qt::WindowModal);
w->showFullScreen();
w->raise();
MainWindow::jump(w);
}
void PrimeWindow::on_helpButton_clicked()
{
}
|
9e1f8d093
김태훈
엔코더 구현 대비 선행 수정
|
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
|
void PrimeWindow::onEncoderLeft()
{
focusPreviousChild();
}
void PrimeWindow::onEncoderRight()
{
focusNextChild();
}
void PrimeWindow::onEncoderClicked(QWidget *clicked)
{
QPushButton *b = qobject_cast<QPushButton *>(clicked);
if (b)
b->click();
}
|