b85726132
김태훈
부가 기능 UI 추가
|
1
2
|
#include "primewindow.h"
#include "ui_primewindow.h"
|
f588aa273
김태훈
부가 기능 로직 추가
|
3
4
5
6
7
8
|
#include <QtDebug>
#include <QLabel>
#include <QPainter>
#include "manualcooksettingwidget.h"
#include "cookhistory.h"
|
bbd7d8f29
김태훈
버튼 음향 추가
|
9
|
#include "soundplayer.h"
|
b85726132
김태훈
부가 기능 UI 추가
|
10
11
12
13
14
15
16
17
18
19
20
|
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
김태훈
부가 기능 로직 추가
|
21
22
|
lastInfoDisplayed = NULL;
|
bbd7d8f29
김태훈
버튼 음향 추가
|
23
24
25
|
foreach (QPushButton *button, findChildren<QPushButton *>())
connect(button, &QPushButton::pressed, SoundPlayer::playClick);
|
b85726132
김태훈
부가 기능 UI 추가
|
26
27
28
29
30
31
|
}
PrimeWindow::~PrimeWindow()
{
delete ui;
}
|
f588aa273
김태훈
부가 기능 로직 추가
|
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
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
|
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)
{
qDebug() << "Favorite ID" << b->record.id;
if (b->record.id == id)
{
// b->setFocus();
b->focusBar();
break;
}
}
}
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 추가
|
181
182
183
184
|
void PrimeWindow::on_backButton_clicked()
{
close();
}
|