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);
|
98f4a2932
김태훈
엔코더 구현
|
30
31
|
setFocus();
|
b85726132
김태훈
부가 기능 UI 추가
|
32
33
34
35
36
37
|
}
PrimeWindow::~PrimeWindow()
{
delete ui;
}
|
f588aa273
김태훈
부가 기능 로직 추가
|
38
39
40
41
42
43
44
45
|
void PrimeWindow::listMostCooked()
{
if (!ui->mostCookedButton->isChecked())
{
ui->mostCookedButton->blockSignals(true);
ui->mostCookedButton->setChecked(true);
ui->mostCookedButton->blockSignals(false);
}
|
98f4a2932
김태훈
엔코더 구현
|
46
47
48
49
50
|
if (ui->recentsButton->isChecked())
ui->recentsButton->setChecked(false);
if (ui->favoritesButton->isChecked())
ui->favoritesButton->setChecked(false);
|
f588aa273
김태훈
부가 기능 로직 추가
|
51
52
53
54
55
56
57
58
59
60
61
|
listButtons(CookHistory::listMostCooked());
}
void PrimeWindow::listRecents()
{
if (!ui->recentsButton->isChecked())
{
ui->recentsButton->blockSignals(true);
ui->recentsButton->setChecked(true);
ui->recentsButton->blockSignals(false);
}
|
98f4a2932
김태훈
엔코더 구현
|
62
63
64
65
66
|
if (ui->mostCookedButton->isChecked())
ui->mostCookedButton->setChecked(false);
if (ui->favoritesButton->isChecked())
ui->favoritesButton->setChecked(false);
|
f588aa273
김태훈
부가 기능 로직 추가
|
67
68
69
70
71
72
73
74
75
76
77
|
listButtons(CookHistory::listRecents());
}
void PrimeWindow::listFavorites()
{
if (!ui->favoritesButton->isChecked())
{
ui->favoritesButton->blockSignals(true);
ui->favoritesButton->setChecked(true);
ui->favoritesButton->blockSignals(false);
}
|
98f4a2932
김태훈
엔코더 구현
|
78
79
80
81
82
|
if (ui->mostCookedButton->isChecked())
ui->mostCookedButton->setChecked(false);
if (ui->recentsButton->isChecked())
ui->recentsButton->setChecked(false);
|
f588aa273
김태훈
부가 기능 로직 추가
|
83
84
85
86
87
88
89
|
listButtons(CookHistory::listFavorites());
}
void PrimeWindow::focusFavorite(int id)
{
foreach (CookPanelButton *b, list)
{
|
f588aa273
김태훈
부가 기능 로직 추가
|
90
91
|
if (b->record.id == id)
{
|
f588aa273
김태훈
부가 기능 로직 추가
|
92
93
94
95
96
|
b->focusBar();
break;
}
}
}
|
9e1f8d093
김태훈
엔코더 구현 대비 선행 수정
|
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
|
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
김태훈
부가 기능 로직 추가
|
131
132
|
void PrimeWindow::on_mostCookedButton_toggled(bool checked)
{
|
e161e8d40
김태훈
버그 수정
|
133
134
135
136
137
138
139
140
141
142
143
|
if (checked)
listMostCooked();
else
{
if (!ui->recentsButton->isChecked() && !ui->favoritesButton->isChecked())
{
ui->mostCookedButton->blockSignals(true);
ui->mostCookedButton->setChecked(true);
ui->mostCookedButton->blockSignals(false);
}
}
|
f588aa273
김태훈
부가 기능 로직 추가
|
144
145
146
147
|
}
void PrimeWindow::on_recentsButton_toggled(bool checked)
{
|
e161e8d40
김태훈
버그 수정
|
148
149
150
151
152
153
154
155
156
157
158
|
if (checked)
listRecents();
else
{
if (!ui->mostCookedButton->isChecked() && !ui->favoritesButton->isChecked())
{
ui->recentsButton->blockSignals(true);
ui->recentsButton->setChecked(true);
ui->recentsButton->blockSignals(false);
}
}
|
f588aa273
김태훈
부가 기능 로직 추가
|
159
160
161
162
|
}
void PrimeWindow::on_favoritesButton_toggled(bool checked)
{
|
e161e8d40
김태훈
버그 수정
|
163
164
165
166
167
168
169
170
171
172
173
|
if (checked)
listFavorites();
else
{
if (!ui->mostCookedButton->isChecked() && !ui->recentsButton->isChecked())
{
ui->favoritesButton->blockSignals(true);
ui->favoritesButton->setChecked(true);
ui->favoritesButton->blockSignals(false);
}
}
|
f588aa273
김태훈
부가 기능 로직 추가
|
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
216
217
218
219
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
245
246
247
248
249
250
|
}
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 추가
|
251
252
253
254
|
void PrimeWindow::on_backButton_clicked()
{
close();
}
|
e00c6a2a9
김태훈
기능 추가 구현
|
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
|
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
김태훈
엔코더 구현 대비 선행 수정
|
280
281
282
|
void PrimeWindow::onEncoderLeft()
{
|
98f4a2932
김태훈
엔코더 구현
|
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
|
QWidget *focused = focusWidget();
if (focused == this || focused == NULL)
ui->helpButton->setFocus();
else if (list.size() > 0)
{
if (focused == ui->backButton)
list.last()->focusDeleteButton();
else if (focused == list.first()->bar())
ui->favoritesButton->setFocus();
else if (focused == ui->mostCookedButton)
ui->helpButton->setFocus();
else
focusPreviousChild();
ui->scrollArea->ensureWidgetVisible(focusWidget());
}
else
focusPreviousChild();
|
9e1f8d093
김태훈
엔코더 구현 대비 선행 수정
|
301
302
303
304
|
}
void PrimeWindow::onEncoderRight()
{
|
98f4a2932
김태훈
엔코더 구현
|
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
|
QWidget *focused = focusWidget();
if (focused == this || focused == NULL)
ui->mostCookedButton->setFocus();
else if (list.size() > 0)
{
if (focused == ui->favoritesButton)
list.first()->focusBar();
else if (focused == list.last()->deleteButton())
ui->backButton->setFocus();
else if (focused == ui->helpButton)
ui->mostCookedButton->setFocus();
else
focusNextChild();
ui->scrollArea->ensureWidgetVisible(focusWidget());
}
else
focusNextChild();
|
9e1f8d093
김태훈
엔코더 구현 대비 선행 수정
|
323
324
325
326
327
328
329
330
|
}
void PrimeWindow::onEncoderClicked(QWidget *clicked)
{
QPushButton *b = qobject_cast<QPushButton *>(clicked);
if (b)
b->click();
}
|