Commit 98f4a2932f34966c4102a3d028e2be64f95364a4

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

엔코더 구현

- 자동 요리 화면
- 부가 기능 화면
app/gui/oven_control/autocookwindow.cpp
... ... @@ -100,6 +100,8 @@ AutoCookWindow::AutoCookWindow(QWidget *parent, Cook cook) :
100 100 updateViewTimer.start(100);
101 101  
102 102 SoundPlayer::playStart();
  103 +
  104 + setFocus();
103 105 }
104 106  
105 107 AutoCookWindow::~AutoCookWindow()
... ... @@ -273,17 +275,19 @@ void AutoCookWindow::setupUi()
273 275  
274 276 void AutoCookWindow::onEncoderLeft()
275 277 {
276   -
  278 + focusPreviousChild();
277 279 }
278 280  
279 281 void AutoCookWindow::onEncoderRight()
280 282 {
281   -
  283 + focusNextChild();
282 284 }
283 285  
284 286 void AutoCookWindow::onEncoderClicked(QWidget *clicked)
285 287 {
286   -
  288 + QPushButton *b = qobject_cast<QPushButton *>(clicked);
  289 + if (b)
  290 + b->click();
287 291 }
288 292  
289 293 void AutoCookWindow::updateView()
... ...
app/gui/oven_control/autocookwindow.ui
... ... @@ -545,6 +545,9 @@ QPushButton::pressed, QPushButton:focus { border-image: url(:/images/button/152_
545 545 <height>290</height>
546 546 </rect>
547 547 </property>
  548 + <property name="focusPolicy">
  549 + <enum>Qt::NoFocus</enum>
  550 + </property>
548 551 <property name="styleSheet">
549 552 <string notr="true">border: #000000</string>
550 553 </property>
... ... @@ -791,6 +794,9 @@ QPushButton::pressed, QPushButton:focus { border-image: url(:/images/symbol/info
791 794 <height>290</height>
792 795 </rect>
793 796 </property>
  797 + <property name="focusPolicy">
  798 + <enum>Qt::NoFocus</enum>
  799 + </property>
794 800 <property name="styleSheet">
795 801 <string notr="true">border: #000000</string>
796 802 </property>
... ... @@ -1398,6 +1404,22 @@ QPushButton:pressed, QPushButton:focus { border-image: url(:/images/button/152_o
1398 1404 <container>1</container>
1399 1405 </customwidget>
1400 1406 </customwidgets>
  1407 + <tabstops>
  1408 + <tabstop>selectCookButton</tabstop>
  1409 + <tabstop>homeButton</tabstop>
  1410 + <tabstop>configCookButton</tabstop>
  1411 + <tabstop>showPrevStepButton</tabstop>
  1412 + <tabstop>showNextStepButton</tabstop>
  1413 + <tabstop>infoButton</tabstop>
  1414 + <tabstop>processButton_1</tabstop>
  1415 + <tabstop>processButton_2</tabstop>
  1416 + <tabstop>processButton_3</tabstop>
  1417 + <tabstop>backButton</tabstop>
  1418 + <tabstop>configButton</tabstop>
  1419 + <tabstop>favoritesButton</tabstop>
  1420 + <tabstop>washButton</tabstop>
  1421 + <tabstop>helpButton</tabstop>
  1422 + </tabstops>
1401 1423 <resources>
1402 1424 <include location="resources.qrc"/>
1403 1425 </resources>
... ...
app/gui/oven_control/cookpanelbutton.cpp
... ... @@ -76,48 +76,58 @@ void CookPanelButton::setLongPressEnabled(bool enabled)
76 76 longPressEnabled = enabled;
77 77 }
78 78  
79   -void CookPanelButton::setEnabled(bool enabled)
  79 +QPushButton *CookPanelButton::bar()
80 80 {
81   - ui->pushButton->setEnabled(enabled);
82   - ui->showInfoButton->setEnabled(enabled);
83   - ui->deleteButton->setEnabled(enabled);
  81 + return ui->pushButton;
84 82 }
85 83  
86   -void CookPanelButton::keyPressEvent(QKeyEvent *event)
  84 +QPushButton *CookPanelButton::deleteButton()
87 85 {
88   - switch (event->key())
89   - {
90   - case 0x01000030: // Turn left
91   - onEncoderLeft();
92   - break;
93   - case 0x01000031: // Push
94   - pushed = focusWidget();
95   - break;
96   - case 0x01000032: // Turn right
97   - onEncoderRight();
98   - break;
99   - }
  86 + return ui->deleteButton;
100 87 }
101 88  
102   -void CookPanelButton::keyReleaseEvent(QKeyEvent *event)
  89 +void CookPanelButton::setEnabled(bool enabled)
103 90 {
104   - switch (event->key())
105   - {
106   - case 0x01000030: // Turn left
107   - onEncoderLeft();
108   - break;
109   - case 0x01000031: // Push
110   - if (focusWidget() == pushed)
111   - onEncoderClicked(pushed);
112   -
113   - pushed = NULL;
114   - break;
115   - case 0x01000032: // Turn right
116   - onEncoderRight();
117   - break;
118   - }
  91 + ui->pushButton->setEnabled(enabled);
  92 + ui->showInfoButton->setEnabled(enabled);
  93 + ui->deleteButton->setEnabled(enabled);
119 94 }
120 95  
  96 +//void CookPanelButton::keyPressEvent(QKeyEvent *event)
  97 +//{
  98 +// switch (event->key())
  99 +// {
  100 +// case 0x01000030: // Turn left
  101 +// onEncoderLeft();
  102 +// break;
  103 +// case 0x01000031: // Push
  104 +// pushed = focusWidget();
  105 +// break;
  106 +// case 0x01000032: // Turn right
  107 +// onEncoderRight();
  108 +// break;
  109 +// }
  110 +//}
  111 +
  112 +//void CookPanelButton::keyReleaseEvent(QKeyEvent *event)
  113 +//{
  114 +// switch (event->key())
  115 +// {
  116 +// case 0x01000030: // Turn left
  117 +// onEncoderLeft();
  118 +// break;
  119 +// case 0x01000031: // Push
  120 +// if (focusWidget() == pushed)
  121 +// onEncoderClicked(pushed);
  122 +
  123 +// pushed = NULL;
  124 +// break;
  125 +// case 0x01000032: // Turn right
  126 +// onEncoderRight();
  127 +// break;
  128 +// }
  129 +//}
  130 +
121 131 void CookPanelButton::emitLongPressed()
122 132 {
123 133 emitted = true;
... ...
app/gui/oven_control/cookpanelbutton.h
... ... @@ -5,6 +5,7 @@
5 5 #include <QLabel>
6 6 #include <QButtonGroup>
7 7 #include <QTimer>
  8 +#include <QPushButton>
8 9  
9 10 #include "cookhistory.h"
10 11  
... ... @@ -37,14 +38,17 @@ public:
37 38  
38 39 void setLongPressEnabled(bool enabled);
39 40  
  41 + QPushButton *bar();
  42 + QPushButton *deleteButton();
  43 +
40 44 CookRecord record;
41 45  
42 46 public slots:
43 47 void setEnabled(bool enabled = true);
44 48  
45 49 protected:
46   - void keyPressEvent(QKeyEvent *event);
47   - void keyReleaseEvent(QKeyEvent *event);
  50 +// void keyPressEvent(QKeyEvent *event);
  51 +// void keyReleaseEvent(QKeyEvent *event);
48 52  
49 53 private slots:
50 54 void emitLongPressed();
... ...
app/gui/oven_control/primewindow.cpp
... ... @@ -28,6 +28,8 @@ PrimeWindow::PrimeWindow(QWidget *parent) :
28 28  
29 29 foreach (QPushButton *button, findChildren<QPushButton *>())
30 30 connect(button, &QPushButton::pressed, SoundPlayer::playClick);
  31 +
  32 + setFocus();
31 33 }
32 34  
33 35 PrimeWindow::~PrimeWindow()
... ... @@ -44,6 +46,12 @@ void PrimeWindow::listMostCooked()
44 46 ui->mostCookedButton->blockSignals(false);
45 47 }
46 48  
  49 + if (ui->recentsButton->isChecked())
  50 + ui->recentsButton->setChecked(false);
  51 +
  52 + if (ui->favoritesButton->isChecked())
  53 + ui->favoritesButton->setChecked(false);
  54 +
47 55 listButtons(CookHistory::listMostCooked());
48 56 }
49 57  
... ... @@ -56,6 +64,12 @@ void PrimeWindow::listRecents()
56 64 ui->recentsButton->blockSignals(false);
57 65 }
58 66  
  67 + if (ui->mostCookedButton->isChecked())
  68 + ui->mostCookedButton->setChecked(false);
  69 +
  70 + if (ui->favoritesButton->isChecked())
  71 + ui->favoritesButton->setChecked(false);
  72 +
59 73 listButtons(CookHistory::listRecents());
60 74 }
61 75  
... ... @@ -68,6 +82,12 @@ void PrimeWindow::listFavorites()
68 82 ui->favoritesButton->blockSignals(false);
69 83 }
70 84  
  85 + if (ui->mostCookedButton->isChecked())
  86 + ui->mostCookedButton->setChecked(false);
  87 +
  88 + if (ui->recentsButton->isChecked())
  89 + ui->recentsButton->setChecked(false);
  90 +
71 91 listButtons(CookHistory::listFavorites());
72 92 }
73 93  
... ... @@ -123,7 +143,8 @@ void PrimeWindow::on_mostCookedButton_toggled(bool checked)
123 143 if (!checked)
124 144 return;
125 145  
126   - listButtons(CookHistory::listMostCooked());
  146 +// listButtons(CookHistory::listMostCooked());
  147 + listMostCooked();
127 148 }
128 149  
129 150 void PrimeWindow::on_recentsButton_toggled(bool checked)
... ... @@ -131,7 +152,8 @@ void PrimeWindow::on_recentsButton_toggled(bool checked)
131 152 if (!checked)
132 153 return;
133 154  
134   - listButtons(CookHistory::listRecents());
  155 +// listButtons(CookHistory::listRecents());
  156 + listRecents();
135 157 }
136 158  
137 159 void PrimeWindow::on_favoritesButton_toggled(bool checked)
... ... @@ -139,7 +161,8 @@ void PrimeWindow::on_favoritesButton_toggled(bool checked)
139 161 if (!checked)
140 162 return;
141 163  
142   - listButtons(CookHistory::listFavorites());
  164 +// listButtons(CookHistory::listFavorites());
  165 + listFavorites();
143 166 }
144 167  
145 168 void PrimeWindow::listButtons(QList<CookRecord> records)
... ... @@ -251,12 +274,46 @@ void PrimeWindow::on_helpButton_clicked()
251 274  
252 275 void PrimeWindow::onEncoderLeft()
253 276 {
254   - focusPreviousChild();
  277 + QWidget *focused = focusWidget();
  278 + if (focused == this || focused == NULL)
  279 + ui->helpButton->setFocus();
  280 + else if (list.size() > 0)
  281 + {
  282 + if (focused == ui->backButton)
  283 + list.last()->focusDeleteButton();
  284 + else if (focused == list.first()->bar())
  285 + ui->favoritesButton->setFocus();
  286 + else if (focused == ui->mostCookedButton)
  287 + ui->helpButton->setFocus();
  288 + else
  289 + focusPreviousChild();
  290 +
  291 + ui->scrollArea->ensureWidgetVisible(focusWidget());
  292 + }
  293 + else
  294 + focusPreviousChild();
255 295 }
256 296  
257 297 void PrimeWindow::onEncoderRight()
258 298 {
259   - focusNextChild();
  299 + QWidget *focused = focusWidget();
  300 + if (focused == this || focused == NULL)
  301 + ui->mostCookedButton->setFocus();
  302 + else if (list.size() > 0)
  303 + {
  304 + if (focused == ui->favoritesButton)
  305 + list.first()->focusBar();
  306 + else if (focused == list.last()->deleteButton())
  307 + ui->backButton->setFocus();
  308 + else if (focused == ui->helpButton)
  309 + ui->mostCookedButton->setFocus();
  310 + else
  311 + focusNextChild();
  312 +
  313 + ui->scrollArea->ensureWidgetVisible(focusWidget());
  314 + }
  315 + else
  316 + focusNextChild();
260 317 }
261 318  
262 319 void PrimeWindow::onEncoderClicked(QWidget *clicked)
... ...
app/gui/oven_control/primewindow.ui
... ... @@ -59,99 +59,6 @@ background: none;
59 59 }</string>
60 60 </property>
61 61 <widget class="QWidget" name="centralwidget">
62   - <widget class="QWidget" name="horizontalLayoutWidget">
63   - <property name="geometry">
64   - <rect>
65   - <x>0</x>
66   - <y>426</y>
67   - <width>900</width>
68   - <height>221</height>
69   - </rect>
70   - </property>
71   - <layout class="QHBoxLayout" name="horizontalLayout">
72   - <property name="spacing">
73   - <number>0</number>
74   - </property>
75   - <item>
76   - <widget class="QPushButton" name="mostCookedButton">
77   - <property name="sizePolicy">
78   - <sizepolicy hsizetype="Minimum" vsizetype="Expanding">
79   - <horstretch>0</horstretch>
80   - <verstretch>0</verstretch>
81   - </sizepolicy>
82   - </property>
83   - <property name="styleSheet">
84   - <string notr="true">QPushButton { background-image: url(:/images/etc/main_btn_04.png); }
85   -QPushButton:pressed, QPushButton:focus { background-image: url(:/images/etc/main_btn_04_ov.png); }</string>
86   - </property>
87   - <property name="text">
88   - <string>선호 요리</string>
89   - </property>
90   - <property name="checkable">
91   - <bool>true</bool>
92   - </property>
93   - <property name="autoExclusive">
94   - <bool>true</bool>
95   - </property>
96   - <property name="style" stdset="0">
97   - <string notr="true">mode</string>
98   - </property>
99   - </widget>
100   - </item>
101   - <item>
102   - <widget class="QPushButton" name="recentsButton">
103   - <property name="sizePolicy">
104   - <sizepolicy hsizetype="Minimum" vsizetype="Expanding">
105   - <horstretch>0</horstretch>
106   - <verstretch>0</verstretch>
107   - </sizepolicy>
108   - </property>
109   - <property name="styleSheet">
110   - <string notr="true">QPushButton { background-image: url(:/images/etc/main_btn_03.png); }
111   -QPushButton:pressed, QPushButton:focus { background-image: url(:/images/etc/main_btn_03_ov.png); }</string>
112   - </property>
113   - <property name="text">
114   - <string>최근 요리</string>
115   - </property>
116   - <property name="checkable">
117   - <bool>true</bool>
118   - </property>
119   - <property name="autoExclusive">
120   - <bool>true</bool>
121   - </property>
122   - <property name="style" stdset="0">
123   - <string notr="true">mode</string>
124   - </property>
125   - </widget>
126   - </item>
127   - <item>
128   - <widget class="QPushButton" name="favoritesButton">
129   - <property name="sizePolicy">
130   - <sizepolicy hsizetype="Minimum" vsizetype="Expanding">
131   - <horstretch>0</horstretch>
132   - <verstretch>0</verstretch>
133   - </sizepolicy>
134   - </property>
135   - <property name="styleSheet">
136   - <string notr="true">QPushButton { background-image: url(:/images/etc/main_btn_05.png); }
137   -QPushButton:pressed, QPushButton:focus { background-image: url(:/images/etc/main_btn_05_ov.png); }</string>
138   - </property>
139   - <property name="text">
140   - <string>즐겨찾기</string>
141   - </property>
142   - <property name="checkable">
143   - <bool>true</bool>
144   - </property>
145   - <property name="autoExclusive">
146   - <bool>true</bool>
147   - </property>
148   - <property name="style" stdset="0">
149   - <string notr="true">mode</string>
150   - </property>
151   - </widget>
152   - </item>
153   - </layout>
154   - </widget>
155 62 <widget class="QWidget" name="bottomBar" native="true">
156 63 <property name="geometry">
157 64 <rect>
... ... @@ -174,9 +81,6 @@ QPushButton:pressed, QPushButton:focus { background-image: url(:/images/etc/main
174 81 <string notr="true">QPushButton { border-image: url(:/images/bottom_bar/back.png); }
175 82 QPushButton:pressed, QPushButton:focus { border-image: url(:/images/bottom_bar/back_ov.png); }</string>
176 83 </property>
177   - <property name="text">
178   - <string/>
179   - </property>
180 84 </widget>
181 85 <widget class="QPushButton" name="washButton">
182 86 <property name="geometry">
... ... @@ -191,9 +95,6 @@ QPushButton:pressed, QPushButton:focus { border-image: url(:/images/bottom_bar/b
191 95 <string notr="true">QPushButton { border-image: url(:/images/bottom_bar/wash.png); }
192 96 QPushButton:pressed, QPushButton:focus { border-image: url(:/images/bottom_bar/wash_ov.png); }</string>
193 97 </property>
194   - <property name="text">
195   - <string/>
196   - </property>
197 98 </widget>
198 99 <widget class="QPushButton" name="helpButton">
199 100 <property name="geometry">
... ... @@ -208,9 +109,6 @@ QPushButton:pressed, QPushButton:focus { border-image: url(:/images/bottom_bar/w
208 109 <string notr="true">QPushButton { border-image: url(:/images/bottom_bar/help.png); }
209 110 QPushButton:pressed, QPushButton:focus { border-image: url(:/images/bottom_bar/help_ov.png); }</string>
210 111 </property>
211   - <property name="text">
212   - <string/>
213   - </property>
214 112 </widget>
215 113 <widget class="QPushButton" name="configButton">
216 114 <property name="geometry">
... ... @@ -231,9 +129,6 @@ QPushButton:pressed, QPushButton:focus { border-image: url(:/images/bottom_bar/h
231 129 <string notr="true">QPushButton { border-image: url(:/images/bottom_bar/config.png); }
232 130 QPushButton:pressed, QPushButton:focus { border-image: url(:/images/bottom_bar/config_ov.png); }</string>
233 131 </property>
234   - <property name="text">
235   - <string/>
236   - </property>
237 132 </widget>
238 133 </widget>
239 134 <widget class="QStackedWidget" name="upperStack">
... ... @@ -281,6 +176,9 @@ QPushButton:pressed, QPushButton:focus { border-image: url(:/images/bottom_bar/c
281 176 <height>803</height>
282 177 </rect>
283 178 </property>
  179 + <property name="focusPolicy">
  180 + <enum>Qt::NoFocus</enum>
  181 + </property>
284 182 <property name="widgetResizable">
285 183 <bool>true</bool>
286 184 </property>
... ... @@ -309,6 +207,93 @@ QPushButton:pressed, QPushButton:focus { border-image: url(:/images/bottom_bar/c
309 207 </layout>
310 208 </widget>
311 209 </widget>
  210 + <widget class="QPushButton" name="mostCookedButton">
  211 + <property name="geometry">
  212 + <rect>
  213 + <x>1</x>
  214 + <y>427</y>
  215 + <width>299</width>
  216 + <height>219</height>
  217 + </rect>
  218 + </property>
  219 + <property name="sizePolicy">
  220 + <sizepolicy hsizetype="Minimum" vsizetype="Expanding">
  221 + <horstretch>0</horstretch>
  222 + <verstretch>0</verstretch>
  223 + </sizepolicy>
  224 + </property>
  225 + <property name="styleSheet">
  226 + <string notr="true">QPushButton { background-image: url(:/images/etc/main_btn_04.png); }
  227 +QPushButton:pressed, QPushButton:focus { background-image: url(:/images/etc/main_btn_04_ov.png); }</string>
  228 + </property>
  229 + <property name="text">
  230 + <string>선호 요리</string>
  231 + </property>
  232 + <property name="checkable">
  233 + <bool>true</bool>
  234 + </property>
  235 + <property name="style" stdset="0">
  236 + <string notr="true">mode</string>
  237 + </property>
  238 + </widget>
  239 + <widget class="QPushButton" name="favoritesButton">
  240 + <property name="geometry">
  241 + <rect>
  242 + <x>600</x>
  243 + <y>427</y>
  244 + <width>299</width>
  245 + <height>219</height>
  246 + </rect>
  247 + </property>
  248 + <property name="sizePolicy">
  249 + <sizepolicy hsizetype="Minimum" vsizetype="Expanding">
  250 + <horstretch>0</horstretch>
  251 + <verstretch>0</verstretch>
  252 + </sizepolicy>
  253 + </property>
  254 + <property name="styleSheet">
  255 + <string notr="true">QPushButton { background-image: url(:/images/etc/main_btn_05.png); }
  256 +QPushButton:pressed, QPushButton:focus { background-image: url(:/images/etc/main_btn_05_ov.png); }</string>
  257 + </property>
  258 + <property name="text">
  259 + <string>즐겨찾기</string>
  260 + </property>
  261 + <property name="checkable">
  262 + <bool>true</bool>
  263 + </property>
  264 + <property name="style" stdset="0">
  265 + <string notr="true">mode</string>
  266 + </property>
  267 + </widget>
  268 + <widget class="QPushButton" name="recentsButton">
  269 + <property name="geometry">
  270 + <rect>
  271 + <x>300</x>
  272 + <y>427</y>
  273 + <width>299</width>
  274 + <height>219</height>
  275 + </rect>
  276 + </property>
  277 + <property name="sizePolicy">
  278 + <sizepolicy hsizetype="Minimum" vsizetype="Expanding">
  279 + <horstretch>0</horstretch>
  280 + <verstretch>0</verstretch>
  281 + </sizepolicy>
  282 + </property>
  283 + <property name="styleSheet">
  284 + <string notr="true">QPushButton { background-image: url(:/images/etc/main_btn_03.png); }
  285 +QPushButton:pressed, QPushButton:focus { background-image: url(:/images/etc/main_btn_03_ov.png); }</string>
  286 + </property>
  287 + <property name="text">
  288 + <string>최근 요리</string>
  289 + </property>
  290 + <property name="checkable">
  291 + <bool>true</bool>
  292 + </property>
  293 + <property name="style" stdset="0">
  294 + <string notr="true">mode</string>
  295 + </property>
  296 + </widget>
312 297 </widget>
313 298 </widget>
314 299 <customwidgets>
... ... @@ -324,6 +309,15 @@ QPushButton:pressed, QPushButton:focus { border-image: url(:/images/bottom_bar/c
324 309 <header>washwarnicon.h</header>
325 310 </customwidget>
326 311 </customwidgets>
  312 + <tabstops>
  313 + <tabstop>mostCookedButton</tabstop>
  314 + <tabstop>recentsButton</tabstop>
  315 + <tabstop>favoritesButton</tabstop>
  316 + <tabstop>backButton</tabstop>
  317 + <tabstop>configButton</tabstop>
  318 + <tabstop>washButton</tabstop>
  319 + <tabstop>helpButton</tabstop>
  320 + </tabstops>
327 321 <resources/>
328 322 <connections/>
329 323 </ui>
... ...