Commit 3f52600cc443b0db57a4206c636e41062c8e1dc2

Authored by 김태훈
1 parent a366f320c8
Exists in master and in 2 other branches fhd, fhd-demo

소스 코드 구조 개선

- Oven 객체를 싱글톤으로 바꾼 걸 Oven 객체를 사용하는 다른 모든 곳에 적용
 - 중복되는 부분을 모아 한 곳에서 처리
app/gui/oven_control/autocookconfigwindow.cpp
... ... @@ -3,10 +3,9 @@
3 3  
4 4 #include "autocookwindow.h"
5 5  
6   -AutoCookConfigWindow::AutoCookConfigWindow(QWidget *parent, Oven *oven, Cook cook) :
  6 +AutoCookConfigWindow::AutoCookConfigWindow(QWidget *parent, Cook cook) :
7 7 QMainWindow(parent),
8 8 ui(new Ui::AutoCookConfigWindow),
9   - oven(oven),
10 9 cook(cook)
11 10 {
12 11 ui->setupUi(this);
... ...
app/gui/oven_control/autocookconfigwindow.h
... ... @@ -20,8 +20,7 @@ class AutoCookConfigWindow : public QMainWindow
20 20 Q_OBJECT
21 21  
22 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 24 ~AutoCookConfigWindow();
26 25  
27 26 private:
... ...
app/gui/oven_control/autocookselectionwindow.cpp
... ... @@ -7,10 +7,10 @@
7 7 #include "autocookconfigwindow.h"
8 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 11 QMainWindow(parent),
12 12 ui(new Ui::AutoCookSelectionWindow),
13   - oven(oven), type(type), autoCookWindowOpened(false)
  13 + type(type), autoCookWindowOpened(false)
14 14 {
15 15 ui->setupUi(this);
16 16  
... ... @@ -67,7 +67,7 @@ void AutoCookSelectionWindow::onCookSelected(int idx)
67 67  
68 68 close();
69 69  
70   - AutoCookConfigWindow *w = new AutoCookConfigWindow(parentWidget(), oven, book.get(idx));
  70 + AutoCookConfigWindow *w = new AutoCookConfigWindow(parentWidget(), book.get(idx));
71 71 w->setWindowModality(Qt::WindowModal);
72 72 w->showFullScreen();
73 73 w->raise();
... ...
app/gui/oven_control/autocookselectionwindow.h
... ... @@ -15,7 +15,7 @@ class AutoCookSelectionWindow : public QMainWindow
15 15 Q_OBJECT
16 16  
17 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 19 ~AutoCookSelectionWindow();
20 20  
21 21 private slots:
... ... @@ -25,7 +25,6 @@ private slots:
25 25  
26 26 private:
27 27 Ui::AutoCookSelectionWindow *ui;
28   - Oven *oven;
29 28 Define::CookType type;
30 29 CookBook book;
31 30  
... ...
app/gui/oven_control/mainwindow.cpp
... ... @@ -43,7 +43,7 @@ MainWindow::MainWindow(QWidget *parent) :
43 43 connect(ui->dryheatButton, SIGNAL(clicked()), sm, SLOT(map()));
44 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 47 window->setWindowModality(Qt::WindowModal);
48 48 window->hide();
49 49  
... ... @@ -60,6 +60,14 @@ MainWindow::~MainWindow()
60 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 71 void MainWindow::onModeButtonClicked(int mode)
64 72 {
65 73 oven->setDefault((Oven::Mode) mode);
... ... @@ -75,26 +83,17 @@ void MainWindow::on_configButton_clicked()
75 83  
76 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 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 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 99 void MainWindow::on_washButton_clicked()
... ...
app/gui/oven_control/mainwindow.h
... ... @@ -7,6 +7,7 @@
7 7 #include "oven.h"
8 8 #include "udphandler.h"
9 9 #include "ovenstatics.h"
  10 +#include "define.h"
10 11  
11 12 namespace Ui {
12 13 class MainWindow;
... ... @@ -26,6 +27,7 @@ signals:
26 27 void modeButtonClicked();
27 28  
28 29 private slots:
  30 + void showAutoCookSelectionWindow(Define::CookType type);
29 31 void onModeButtonClicked(int mode);
30 32  
31 33 void on_configButton_clicked();
... ...
app/gui/oven_control/manualcookwindow.cpp
... ... @@ -8,9 +8,9 @@
8 8 #include "preheatpopup.h"
9 9 #include "cooldownpopup.h"
10 10  
11   -ManualCookWindow::ManualCookWindow(QWidget *parent, Oven *oven, UdpHandler *udp) :
  11 +ManualCookWindow::ManualCookWindow(QWidget *parent) :
12 12 QMainWindow(parent),
13   - ui(new Ui::ManualCookWindow), oven(oven), udp(udp)
  13 + ui(new Ui::ManualCookWindow)
14 14 {
15 15 ui->setupUi(this);
16 16  
... ... @@ -20,6 +20,7 @@ ManualCookWindow::ManualCookWindow(QWidget *parent, Oven *oven, UdpHandler *udp)
20 20 ui->innerStack->setParent(ui->bodyStack);
21 21 setAttribute(Qt::WA_DeleteOnClose);
22 22  
  23 + oven = Oven::getInstance();
23 24 connect(oven, SIGNAL(changed(Oven*)), this, SLOT(onOvenUpdated(Oven*)));
24 25  
25 26 connect(ui->steamButton, SIGNAL(clicked()), this, SIGNAL(modeButtonClicked()));
... ...
app/gui/oven_control/manualcookwindow.h
... ... @@ -15,7 +15,7 @@ class ManualCookWindow : public QMainWindow
15 15 Q_OBJECT
16 16  
17 17 public:
18   - explicit ManualCookWindow(QWidget *parent = 0, Oven *oven = 0, UdpHandler *udp = 0);
  18 + explicit ManualCookWindow(QWidget *parent = 0);
19 19 ~ManualCookWindow();
20 20  
21 21 signals:
... ... @@ -57,7 +57,6 @@ private slots:
57 57 private:
58 58 Ui::ManualCookWindow *ui;
59 59 Oven *oven;
60   - UdpHandler *udp;
61 60 QTimer *cookingStartTimer;
62 61  
63 62 int humidity;
... ...