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"
|
1342af7b3
김태훈
도움말 버튼 연결
|
14
|
#include "manualviewerdlg.h"
|
b85726132
김태훈
부가 기능 UI 추가
|
15
16
17
18
19
20
21
22
23
24
25
|
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
김태훈
부가 기능 로직 추가
|
26
27
|
lastInfoDisplayed = NULL;
|
bbd7d8f29
김태훈
버튼 음향 추가
|
28
29
30
|
foreach (QPushButton *button, findChildren<QPushButton *>())
connect(button, &QPushButton::pressed, SoundPlayer::playClick);
|
98f4a2932
김태훈
엔코더 구현
|
31
32
|
setFocus();
|
b85726132
김태훈
부가 기능 UI 추가
|
33
34
35
36
37
38
|
}
PrimeWindow::~PrimeWindow()
{
delete ui;
}
|
f588aa273
김태훈
부가 기능 로직 추가
|
39
40
41
42
43
44
45
46
|
void PrimeWindow::listMostCooked()
{
if (!ui->mostCookedButton->isChecked())
{
ui->mostCookedButton->blockSignals(true);
ui->mostCookedButton->setChecked(true);
ui->mostCookedButton->blockSignals(false);
}
|
98f4a2932
김태훈
엔코더 구현
|
47
48
49
50
51
|
if (ui->recentsButton->isChecked())
ui->recentsButton->setChecked(false);
if (ui->favoritesButton->isChecked())
ui->favoritesButton->setChecked(false);
|
f588aa273
김태훈
부가 기능 로직 추가
|
52
53
54
55
56
57
58
59
60
61
62
|
listButtons(CookHistory::listMostCooked());
}
void PrimeWindow::listRecents()
{
if (!ui->recentsButton->isChecked())
{
ui->recentsButton->blockSignals(true);
ui->recentsButton->setChecked(true);
ui->recentsButton->blockSignals(false);
}
|
98f4a2932
김태훈
엔코더 구현
|
63
64
65
66
67
|
if (ui->mostCookedButton->isChecked())
ui->mostCookedButton->setChecked(false);
if (ui->favoritesButton->isChecked())
ui->favoritesButton->setChecked(false);
|
f588aa273
김태훈
부가 기능 로직 추가
|
68
69
70
71
72
73
74
75
76
77
78
|
listButtons(CookHistory::listRecents());
}
void PrimeWindow::listFavorites()
{
if (!ui->favoritesButton->isChecked())
{
ui->favoritesButton->blockSignals(true);
ui->favoritesButton->setChecked(true);
ui->favoritesButton->blockSignals(false);
}
|
98f4a2932
김태훈
엔코더 구현
|
79
80
81
82
83
|
if (ui->mostCookedButton->isChecked())
ui->mostCookedButton->setChecked(false);
if (ui->recentsButton->isChecked())
ui->recentsButton->setChecked(false);
|
f588aa273
김태훈
부가 기능 로직 추가
|
84
85
86
87
88
89
90
|
listButtons(CookHistory::listFavorites());
}
void PrimeWindow::focusFavorite(int id)
{
foreach (CookPanelButton *b, list)
{
|
f588aa273
김태훈
부가 기능 로직 추가
|
91
92
|
if (b->record.id == id)
{
|
f588aa273
김태훈
부가 기능 로직 추가
|
93
94
95
96
97
|
b->focusBar();
break;
}
}
}
|
9e1f8d093
김태훈
엔코더 구현 대비 선행 수정
|
98
99
100
101
|
void PrimeWindow::keyPressEvent(QKeyEvent *event)
{
switch (event->key())
{
|
01249f413
김태훈
엔코더 방향 반전. 하드웨어가 변경됨
|
102
|
case 0x01000032: // Turn left
|
9e1f8d093
김태훈
엔코더 구현 대비 선행 수정
|
103
104
105
106
107
|
onEncoderLeft();
break;
case 0x01000031: // Push
pushed = focusWidget();
break;
|
01249f413
김태훈
엔코더 방향 반전. 하드웨어가 변경됨
|
108
|
case 0x01000030: // Turn right
|
9e1f8d093
김태훈
엔코더 구현 대비 선행 수정
|
109
110
111
112
113
114
115
116
117
|
onEncoderRight();
break;
}
}
void PrimeWindow::keyReleaseEvent(QKeyEvent *event)
{
switch (event->key())
{
|
01249f413
김태훈
엔코더 방향 반전. 하드웨어가 변경됨
|
118
|
case 0x01000032: // Turn left
|
9e1f8d093
김태훈
엔코더 구현 대비 선행 수정
|
119
120
121
122
123
124
125
126
|
onEncoderLeft();
break;
case 0x01000031: // Push
if (focusWidget() == pushed)
onEncoderClicked(pushed);
pushed = NULL;
break;
|
01249f413
김태훈
엔코더 방향 반전. 하드웨어가 변경됨
|
127
|
case 0x01000030: // Turn right
|
9e1f8d093
김태훈
엔코더 구현 대비 선행 수정
|
128
129
130
131
|
onEncoderRight();
break;
}
}
|
f588aa273
김태훈
부가 기능 로직 추가
|
132
133
|
void PrimeWindow::on_mostCookedButton_toggled(bool checked)
{
|
e161e8d40
김태훈
버그 수정
|
134
135
136
137
138
139
140
141
142
143
144
|
if (checked)
listMostCooked();
else
{
if (!ui->recentsButton->isChecked() && !ui->favoritesButton->isChecked())
{
ui->mostCookedButton->blockSignals(true);
ui->mostCookedButton->setChecked(true);
ui->mostCookedButton->blockSignals(false);
}
}
|
f588aa273
김태훈
부가 기능 로직 추가
|
145
146
147
148
|
}
void PrimeWindow::on_recentsButton_toggled(bool checked)
{
|
e161e8d40
김태훈
버그 수정
|
149
150
151
152
153
154
155
156
157
158
159
|
if (checked)
listRecents();
else
{
if (!ui->mostCookedButton->isChecked() && !ui->favoritesButton->isChecked())
{
ui->recentsButton->blockSignals(true);
ui->recentsButton->setChecked(true);
ui->recentsButton->blockSignals(false);
}
}
|
f588aa273
김태훈
부가 기능 로직 추가
|
160
161
162
163
|
}
void PrimeWindow::on_favoritesButton_toggled(bool checked)
{
|
e161e8d40
김태훈
버그 수정
|
164
165
166
167
168
169
170
171
172
173
174
|
if (checked)
listFavorites();
else
{
if (!ui->mostCookedButton->isChecked() && !ui->recentsButton->isChecked())
{
ui->favoritesButton->blockSignals(true);
ui->favoritesButton->setChecked(true);
ui->favoritesButton->blockSignals(false);
}
}
|
f588aa273
김태훈
부가 기능 로직 추가
|
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
251
|
}
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 추가
|
252
253
254
255
|
void PrimeWindow::on_backButton_clicked()
{
close();
}
|
e00c6a2a9
김태훈
기능 추가 구현
|
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
|
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()
{
|
1342af7b3
김태훈
도움말 버튼 연결
|
279
280
281
|
ManualViewerDlg* dlg = new ManualViewerDlg(this);
dlg->showFullScreen();
dlg->raise();
|
e00c6a2a9
김태훈
기능 추가 구현
|
282
|
}
|
9e1f8d093
김태훈
엔코더 구현 대비 선행 수정
|
283
284
285
|
void PrimeWindow::onEncoderLeft()
{
|
98f4a2932
김태훈
엔코더 구현
|
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
|
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
김태훈
엔코더 구현 대비 선행 수정
|
304
305
306
307
|
}
void PrimeWindow::onEncoderRight()
{
|
98f4a2932
김태훈
엔코더 구현
|
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
|
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
김태훈
엔코더 구현 대비 선행 수정
|
326
327
328
329
330
331
332
333
|
}
void PrimeWindow::onEncoderClicked(QWidget *clicked)
{
QPushButton *b = qobject_cast<QPushButton *>(clicked);
if (b)
b->click();
}
|