Commit 3f52600cc443b0db57a4206c636e41062c8e1dc2
1 parent
a366f320c8
Exists in
master
and in
2 other branches
소스 코드 구조 개선
- Oven 객체를 싱글톤으로 바꾼 걸 Oven 객체를 사용하는 다른 모든 곳에 적용 - 중복되는 부분을 모아 한 곳에서 처리
Showing
8 changed files
with
24 additions
and
26 deletions
Show diff stats
app/gui/oven_control/autocookconfigwindow.cpp
@@ -3,10 +3,9 @@ | @@ -3,10 +3,9 @@ | ||
3 | 3 | ||
4 | #include "autocookwindow.h" | 4 | #include "autocookwindow.h" |
5 | 5 | ||
6 | -AutoCookConfigWindow::AutoCookConfigWindow(QWidget *parent, Oven *oven, Cook cook) : | 6 | +AutoCookConfigWindow::AutoCookConfigWindow(QWidget *parent, Cook cook) : |
7 | QMainWindow(parent), | 7 | QMainWindow(parent), |
8 | ui(new Ui::AutoCookConfigWindow), | 8 | ui(new Ui::AutoCookConfigWindow), |
9 | - oven(oven), | ||
10 | cook(cook) | 9 | cook(cook) |
11 | { | 10 | { |
12 | ui->setupUi(this); | 11 | ui->setupUi(this); |
app/gui/oven_control/autocookconfigwindow.h
@@ -20,8 +20,7 @@ class AutoCookConfigWindow : public QMainWindow | @@ -20,8 +20,7 @@ class AutoCookConfigWindow : public QMainWindow | ||
20 | Q_OBJECT | 20 | Q_OBJECT |
21 | 21 | ||
22 | public: | 22 | public: |
23 | - explicit AutoCookConfigWindow(QWidget *parent = 0, Oven *oven = 0, | ||
24 | - Cook cook = Cook(Define::Poultry, "/prime/cookbook/poultry/chicken", "Chicken")); | 23 | + explicit AutoCookConfigWindow(QWidget *parent, Cook cook); |
25 | ~AutoCookConfigWindow(); | 24 | ~AutoCookConfigWindow(); |
26 | 25 | ||
27 | private: | 26 | private: |
app/gui/oven_control/autocookselectionwindow.cpp
@@ -7,10 +7,10 @@ | @@ -7,10 +7,10 @@ | ||
7 | #include "autocookconfigwindow.h" | 7 | #include "autocookconfigwindow.h" |
8 | //#include "autocookwindow.h" | 8 | //#include "autocookwindow.h" |
9 | 9 | ||
10 | -AutoCookSelectionWindow::AutoCookSelectionWindow(QWidget *parent, Oven *oven, Define::CookType type) : | 10 | +AutoCookSelectionWindow::AutoCookSelectionWindow(QWidget *parent, Define::CookType type) : |
11 | QMainWindow(parent), | 11 | QMainWindow(parent), |
12 | ui(new Ui::AutoCookSelectionWindow), | 12 | ui(new Ui::AutoCookSelectionWindow), |
13 | - oven(oven), type(type), autoCookWindowOpened(false) | 13 | + type(type), autoCookWindowOpened(false) |
14 | { | 14 | { |
15 | ui->setupUi(this); | 15 | ui->setupUi(this); |
16 | 16 | ||
@@ -67,7 +67,7 @@ void AutoCookSelectionWindow::onCookSelected(int idx) | @@ -67,7 +67,7 @@ void AutoCookSelectionWindow::onCookSelected(int idx) | ||
67 | 67 | ||
68 | close(); | 68 | close(); |
69 | 69 | ||
70 | - AutoCookConfigWindow *w = new AutoCookConfigWindow(parentWidget(), oven, book.get(idx)); | 70 | + AutoCookConfigWindow *w = new AutoCookConfigWindow(parentWidget(), book.get(idx)); |
71 | w->setWindowModality(Qt::WindowModal); | 71 | w->setWindowModality(Qt::WindowModal); |
72 | w->showFullScreen(); | 72 | w->showFullScreen(); |
73 | w->raise(); | 73 | w->raise(); |
app/gui/oven_control/autocookselectionwindow.h
@@ -15,7 +15,7 @@ class AutoCookSelectionWindow : public QMainWindow | @@ -15,7 +15,7 @@ class AutoCookSelectionWindow : public QMainWindow | ||
15 | Q_OBJECT | 15 | Q_OBJECT |
16 | 16 | ||
17 | public: | 17 | public: |
18 | - explicit AutoCookSelectionWindow(QWidget *parent = 0, Oven *oven = 0, Define::CookType type = Define::Poultry); | 18 | + explicit AutoCookSelectionWindow(QWidget *parent, Define::CookType type); |
19 | ~AutoCookSelectionWindow(); | 19 | ~AutoCookSelectionWindow(); |
20 | 20 | ||
21 | private slots: | 21 | private slots: |
@@ -25,7 +25,6 @@ private slots: | @@ -25,7 +25,6 @@ private slots: | ||
25 | 25 | ||
26 | private: | 26 | private: |
27 | Ui::AutoCookSelectionWindow *ui; | 27 | Ui::AutoCookSelectionWindow *ui; |
28 | - Oven *oven; | ||
29 | Define::CookType type; | 28 | Define::CookType type; |
30 | CookBook book; | 29 | CookBook book; |
31 | 30 |
app/gui/oven_control/mainwindow.cpp
@@ -43,7 +43,7 @@ MainWindow::MainWindow(QWidget *parent) : | @@ -43,7 +43,7 @@ MainWindow::MainWindow(QWidget *parent) : | ||
43 | connect(ui->dryheatButton, SIGNAL(clicked()), sm, SLOT(map())); | 43 | connect(ui->dryheatButton, SIGNAL(clicked()), sm, SLOT(map())); |
44 | connect(sm, SIGNAL(mapped(int)), this, SLOT(onModeButtonClicked(int))); | 44 | connect(sm, SIGNAL(mapped(int)), this, SLOT(onModeButtonClicked(int))); |
45 | 45 | ||
46 | - ManualCookWindow *window = new ManualCookWindow(this, oven, udp); | 46 | + ManualCookWindow *window = new ManualCookWindow(this); |
47 | window->setWindowModality(Qt::WindowModal); | 47 | window->setWindowModality(Qt::WindowModal); |
48 | window->hide(); | 48 | window->hide(); |
49 | 49 | ||
@@ -60,6 +60,14 @@ MainWindow::~MainWindow() | @@ -60,6 +60,14 @@ MainWindow::~MainWindow() | ||
60 | delete ui; | 60 | delete ui; |
61 | } | 61 | } |
62 | 62 | ||
63 | +void MainWindow::showAutoCookSelectionWindow(Define::CookType type) | ||
64 | +{ | ||
65 | + AutoCookSelectionWindow *w = new AutoCookSelectionWindow(this, type); | ||
66 | + w->setWindowModality(Qt::WindowModal); | ||
67 | + w->showFullScreen(); | ||
68 | + w->raise(); | ||
69 | +} | ||
70 | + | ||
63 | void MainWindow::onModeButtonClicked(int mode) | 71 | void MainWindow::onModeButtonClicked(int mode) |
64 | { | 72 | { |
65 | oven->setDefault((Oven::Mode) mode); | 73 | oven->setDefault((Oven::Mode) mode); |
@@ -75,26 +83,17 @@ void MainWindow::on_configButton_clicked() | @@ -75,26 +83,17 @@ void MainWindow::on_configButton_clicked() | ||
75 | 83 | ||
76 | void MainWindow::on_poultryButton_clicked() | 84 | void MainWindow::on_poultryButton_clicked() |
77 | { | 85 | { |
78 | - AutoCookSelectionWindow *w = new AutoCookSelectionWindow(this, oven, Define::Poultry); | ||
79 | - w->setWindowModality(Qt::WindowModal); | ||
80 | - w->showFullScreen(); | ||
81 | - w->raise(); | 86 | + showAutoCookSelectionWindow(Define::Poultry); |
82 | } | 87 | } |
83 | 88 | ||
84 | void MainWindow::on_meatButton_clicked() | 89 | void MainWindow::on_meatButton_clicked() |
85 | { | 90 | { |
86 | - AutoCookSelectionWindow *w = new AutoCookSelectionWindow(this, oven, Define::Meat); | ||
87 | - w->setWindowModality(Qt::WindowModal); | ||
88 | - w->showFullScreen(); | ||
89 | - w->raise(); | 91 | + showAutoCookSelectionWindow(Define::Meat); |
90 | } | 92 | } |
91 | 93 | ||
92 | void MainWindow::on_breadButton_clicked() | 94 | void MainWindow::on_breadButton_clicked() |
93 | { | 95 | { |
94 | - AutoCookSelectionWindow *w = new AutoCookSelectionWindow(this, oven, Define::Bread); | ||
95 | - w->setWindowModality(Qt::WindowModal); | ||
96 | - w->showFullScreen(); | ||
97 | - w->raise(); | 96 | + showAutoCookSelectionWindow(Define::Bread); |
98 | } | 97 | } |
99 | 98 | ||
100 | void MainWindow::on_washButton_clicked() | 99 | void MainWindow::on_washButton_clicked() |
app/gui/oven_control/mainwindow.h
@@ -7,6 +7,7 @@ | @@ -7,6 +7,7 @@ | ||
7 | #include "oven.h" | 7 | #include "oven.h" |
8 | #include "udphandler.h" | 8 | #include "udphandler.h" |
9 | #include "ovenstatics.h" | 9 | #include "ovenstatics.h" |
10 | +#include "define.h" | ||
10 | 11 | ||
11 | namespace Ui { | 12 | namespace Ui { |
12 | class MainWindow; | 13 | class MainWindow; |
@@ -26,6 +27,7 @@ signals: | @@ -26,6 +27,7 @@ signals: | ||
26 | void modeButtonClicked(); | 27 | void modeButtonClicked(); |
27 | 28 | ||
28 | private slots: | 29 | private slots: |
30 | + void showAutoCookSelectionWindow(Define::CookType type); | ||
29 | void onModeButtonClicked(int mode); | 31 | void onModeButtonClicked(int mode); |
30 | 32 | ||
31 | void on_configButton_clicked(); | 33 | void on_configButton_clicked(); |
app/gui/oven_control/manualcookwindow.cpp
@@ -8,9 +8,9 @@ | @@ -8,9 +8,9 @@ | ||
8 | #include "preheatpopup.h" | 8 | #include "preheatpopup.h" |
9 | #include "cooldownpopup.h" | 9 | #include "cooldownpopup.h" |
10 | 10 | ||
11 | -ManualCookWindow::ManualCookWindow(QWidget *parent, Oven *oven, UdpHandler *udp) : | 11 | +ManualCookWindow::ManualCookWindow(QWidget *parent) : |
12 | QMainWindow(parent), | 12 | QMainWindow(parent), |
13 | - ui(new Ui::ManualCookWindow), oven(oven), udp(udp) | 13 | + ui(new Ui::ManualCookWindow) |
14 | { | 14 | { |
15 | ui->setupUi(this); | 15 | ui->setupUi(this); |
16 | 16 | ||
@@ -20,6 +20,7 @@ ManualCookWindow::ManualCookWindow(QWidget *parent, Oven *oven, UdpHandler *udp) | @@ -20,6 +20,7 @@ ManualCookWindow::ManualCookWindow(QWidget *parent, Oven *oven, UdpHandler *udp) | ||
20 | ui->innerStack->setParent(ui->bodyStack); | 20 | ui->innerStack->setParent(ui->bodyStack); |
21 | setAttribute(Qt::WA_DeleteOnClose); | 21 | setAttribute(Qt::WA_DeleteOnClose); |
22 | 22 | ||
23 | + oven = Oven::getInstance(); | ||
23 | connect(oven, SIGNAL(changed(Oven*)), this, SLOT(onOvenUpdated(Oven*))); | 24 | connect(oven, SIGNAL(changed(Oven*)), this, SLOT(onOvenUpdated(Oven*))); |
24 | 25 | ||
25 | connect(ui->steamButton, SIGNAL(clicked()), this, SIGNAL(modeButtonClicked())); | 26 | connect(ui->steamButton, SIGNAL(clicked()), this, SIGNAL(modeButtonClicked())); |
app/gui/oven_control/manualcookwindow.h
@@ -15,7 +15,7 @@ class ManualCookWindow : public QMainWindow | @@ -15,7 +15,7 @@ class ManualCookWindow : public QMainWindow | ||
15 | Q_OBJECT | 15 | Q_OBJECT |
16 | 16 | ||
17 | public: | 17 | public: |
18 | - explicit ManualCookWindow(QWidget *parent = 0, Oven *oven = 0, UdpHandler *udp = 0); | 18 | + explicit ManualCookWindow(QWidget *parent = 0); |
19 | ~ManualCookWindow(); | 19 | ~ManualCookWindow(); |
20 | 20 | ||
21 | signals: | 21 | signals: |
@@ -57,7 +57,6 @@ private slots: | @@ -57,7 +57,6 @@ private slots: | ||
57 | private: | 57 | private: |
58 | Ui::ManualCookWindow *ui; | 58 | Ui::ManualCookWindow *ui; |
59 | Oven *oven; | 59 | Oven *oven; |
60 | - UdpHandler *udp; | ||
61 | QTimer *cookingStartTimer; | 60 | QTimer *cookingStartTimer; |
62 | 61 | ||
63 | int humidity; | 62 | int humidity; |