Commit f5634ecc765a9a1fd31b1feb6e26b0a8d3db706d
1 parent
d804d82b41
Exists in
master
and in
2 other branches
엔코더 구현
- 즐겨찾기 이름 설정 팝업 - 프로그래밍 모드 항목 이름 설정 팝업 - 수동 요리 예약 시간 설정 팝업 - 수동 요리 예약 시간 표시 팝업
Showing
13 changed files
with
296 additions
and
9 deletions
Show diff stats
app/gui/oven_control/favoritenamepopup.cpp
@@ -13,6 +13,12 @@ FavoriteNamePopup::FavoriteNamePopup(QWidget *parent) : | @@ -13,6 +13,12 @@ FavoriteNamePopup::FavoriteNamePopup(QWidget *parent) : | ||
13 | { | 13 | { |
14 | ui->setupUi(this); | 14 | ui->setupUi(this); |
15 | 15 | ||
16 | + connect(ui->keyboard, SIGNAL(onOkKeyClicked()), ui->keyboard, SLOT(focusOutKeyboard())); | ||
17 | + connect(ui->keyboard, SIGNAL(onCancelKeyClicked()), ui->keyboard, SLOT(focusOutKeyboard())); | ||
18 | + connect(ui->keyboard, SIGNAL(onCancelKeyClicked()), SLOT(revert())); | ||
19 | + | ||
20 | + ui->lineEdit->installEventFilter(this); | ||
21 | + | ||
16 | ui->lineEdit->setFocus(); | 22 | ui->lineEdit->setFocus(); |
17 | ui->lineEdit->selectAll(); | 23 | ui->lineEdit->selectAll(); |
18 | 24 | ||
@@ -37,6 +43,20 @@ FavoriteNamePopup::~FavoriteNamePopup() | @@ -37,6 +43,20 @@ FavoriteNamePopup::~FavoriteNamePopup() | ||
37 | delete ui; | 43 | delete ui; |
38 | } | 44 | } |
39 | 45 | ||
46 | +bool FavoriteNamePopup::eventFilter(QObject */*watched*/, QEvent *event) | ||
47 | +{ | ||
48 | + switch (event->type()) | ||
49 | + { | ||
50 | + case QEvent::FocusIn: | ||
51 | + lastLine = ui->lineEdit->text(); | ||
52 | + break; | ||
53 | + default: | ||
54 | + break; | ||
55 | + } | ||
56 | + | ||
57 | + return false; | ||
58 | +} | ||
59 | + | ||
40 | void FavoriteNamePopup::keyPressEvent(QKeyEvent *event) | 60 | void FavoriteNamePopup::keyPressEvent(QKeyEvent *event) |
41 | { | 61 | { |
42 | switch (event->key()) | 62 | switch (event->key()) |
@@ -102,6 +122,14 @@ void FavoriteNamePopup::cancel() | @@ -102,6 +122,14 @@ void FavoriteNamePopup::cancel() | ||
102 | deleteLater(); | 122 | deleteLater(); |
103 | } | 123 | } |
104 | 124 | ||
125 | +void FavoriteNamePopup::revert() | ||
126 | +{ | ||
127 | + ui->lineEdit->setText(lastLine); | ||
128 | + | ||
129 | + if (focusWidget() == ui->lineEdit) | ||
130 | + ui->lineEdit->selectAll(); | ||
131 | +} | ||
132 | + | ||
105 | void FavoriteNamePopup::on_okButton_clicked() | 133 | void FavoriteNamePopup::on_okButton_clicked() |
106 | { | 134 | { |
107 | ok(); | 135 | ok(); |
@@ -114,15 +142,32 @@ void FavoriteNamePopup::on_cancelButton_clicked() | @@ -114,15 +142,32 @@ void FavoriteNamePopup::on_cancelButton_clicked() | ||
114 | 142 | ||
115 | void FavoriteNamePopup::onEncoderLeft() | 143 | void FavoriteNamePopup::onEncoderLeft() |
116 | { | 144 | { |
117 | - | 145 | + if (focusWidget() == ui->lineEdit) |
146 | + ui->cancelButton->setFocus(); | ||
147 | + else | ||
148 | + focusPreviousChild(); | ||
118 | } | 149 | } |
119 | 150 | ||
120 | void FavoriteNamePopup::onEncoderRight() | 151 | void FavoriteNamePopup::onEncoderRight() |
121 | { | 152 | { |
122 | - | 153 | + if (focusWidget() == ui->cancelButton) |
154 | + { | ||
155 | + ui->lineEdit->setFocus(); | ||
156 | + ui->lineEdit->selectAll(); | ||
157 | + } | ||
158 | + else | ||
159 | + focusNextChild(); | ||
123 | } | 160 | } |
124 | 161 | ||
125 | void FavoriteNamePopup::onEncoderClicked(QWidget *clicked) | 162 | void FavoriteNamePopup::onEncoderClicked(QWidget *clicked) |
126 | { | 163 | { |
127 | - | 164 | + QPushButton *b = qobject_cast<QPushButton *>(clicked); |
165 | + if (b) | ||
166 | + b->click(); | ||
167 | + else | ||
168 | + { | ||
169 | + QLineEdit *e = qobject_cast<QLineEdit *>(clicked); | ||
170 | + if (e) | ||
171 | + ui->keyboard->focusInKeyboard(); | ||
172 | + } | ||
128 | } | 173 | } |
app/gui/oven_control/favoritenamepopup.h
@@ -20,6 +20,8 @@ public: | @@ -20,6 +20,8 @@ public: | ||
20 | explicit FavoriteNamePopup(QWidget *parent, AutoCookSetting setting); | 20 | explicit FavoriteNamePopup(QWidget *parent, AutoCookSetting setting); |
21 | ~FavoriteNamePopup(); | 21 | ~FavoriteNamePopup(); |
22 | 22 | ||
23 | + bool eventFilter(QObject *watched, QEvent *event); | ||
24 | + | ||
23 | protected: | 25 | protected: |
24 | void keyPressEvent(QKeyEvent *event); | 26 | void keyPressEvent(QKeyEvent *event); |
25 | void keyReleaseEvent(QKeyEvent *event); | 27 | void keyReleaseEvent(QKeyEvent *event); |
@@ -37,9 +39,12 @@ private: | @@ -37,9 +39,12 @@ private: | ||
37 | void onEncoderRight(); | 39 | void onEncoderRight(); |
38 | void onEncoderClicked(QWidget *clicked); | 40 | void onEncoderClicked(QWidget *clicked); |
39 | 41 | ||
42 | + QString lastLine; | ||
43 | + | ||
40 | private slots: | 44 | private slots: |
41 | void ok(); | 45 | void ok(); |
42 | void cancel(); | 46 | void cancel(); |
47 | + void revert(); | ||
43 | void on_okButton_clicked(); | 48 | void on_okButton_clicked(); |
44 | void on_cancelButton_clicked(); | 49 | void on_cancelButton_clicked(); |
45 | }; | 50 | }; |
app/gui/oven_control/favoritenamepopup.ui
@@ -163,6 +163,11 @@ QPushButton:pressed, QPushButton:focus { color: yellow; }</string> | @@ -163,6 +163,11 @@ QPushButton:pressed, QPushButton:focus { color: yellow; }</string> | ||
163 | <container>1</container> | 163 | <container>1</container> |
164 | </customwidget> | 164 | </customwidget> |
165 | </customwidgets> | 165 | </customwidgets> |
166 | + <tabstops> | ||
167 | + <tabstop>lineEdit</tabstop> | ||
168 | + <tabstop>okButton</tabstop> | ||
169 | + <tabstop>cancelButton</tabstop> | ||
170 | + </tabstops> | ||
166 | <resources/> | 171 | <resources/> |
167 | <connections/> | 172 | <connections/> |
168 | </ui> | 173 | </ui> |
app/gui/oven_control/formatterspinbox.cpp
@@ -30,8 +30,8 @@ FormatterSpinBox::FormatterSpinBox(QWidget *parent) | @@ -30,8 +30,8 @@ FormatterSpinBox::FormatterSpinBox(QWidget *parent) | ||
30 | } | 30 | } |
31 | 31 | ||
32 | void FormatterSpinBox::focusInEvent(QFocusEvent *event){ | 32 | void FormatterSpinBox::focusInEvent(QFocusEvent *event){ |
33 | - qDebug() << "focus in"; | ||
34 | - if(event->reason() == Qt::MouseFocusReason) QTimer::singleShot(200,this,SLOT(selectAll())); | 33 | + QSpinBox::focusInEvent(event); |
34 | + if(event->reason() == Qt::MouseFocusReason) QTimer::singleShot(0,this,SLOT(selectAll())); | ||
35 | else selectAll(); | 35 | else selectAll(); |
36 | emit focusInEdit(); | 36 | emit focusInEdit(); |
37 | } | 37 | } |
app/gui/oven_control/manualcookwindow.cpp
@@ -1018,7 +1018,7 @@ void ManualCookWindow::on_favoriteButton_clicked() | @@ -1018,7 +1018,7 @@ void ManualCookWindow::on_favoriteButton_clicked() | ||
1018 | p->showFullScreen(); | 1018 | p->showFullScreen(); |
1019 | 1019 | ||
1020 | focused = ui->favoriteButton; | 1020 | focused = ui->favoriteButton; |
1021 | - connect(p, SIGNAL(destroyed(QObject*)), SLOT(focusAgain())); | 1021 | + connect(p, SIGNAL(rejected()), SLOT(focusAgain())); |
1022 | connect(p, SIGNAL(accepted()), SLOT(addFavorite())); | 1022 | connect(p, SIGNAL(accepted()), SLOT(addFavorite())); |
1023 | 1023 | ||
1024 | if (startCookingTimer.isActive()) | 1024 | if (startCookingTimer.isActive()) |
app/gui/oven_control/programmingnamepopup.cpp
@@ -14,6 +14,12 @@ ProgrammingNamePopup::ProgrammingNamePopup(QWidget *parent, CookRecord record) : | @@ -14,6 +14,12 @@ ProgrammingNamePopup::ProgrammingNamePopup(QWidget *parent, CookRecord record) : | ||
14 | 14 | ||
15 | setAttribute(Qt::WA_DeleteOnClose); | 15 | setAttribute(Qt::WA_DeleteOnClose); |
16 | 16 | ||
17 | + connect(ui->keyboard, SIGNAL(onOkKeyClicked()), ui->keyboard, SLOT(focusOutKeyboard())); | ||
18 | + connect(ui->keyboard, SIGNAL(onCancelKeyClicked()), ui->keyboard, SLOT(focusOutKeyboard())); | ||
19 | + connect(ui->keyboard, SIGNAL(onCancelKeyClicked()), SLOT(revert())); | ||
20 | + | ||
21 | + ui->lineEdit->installEventFilter(this); | ||
22 | + | ||
17 | ui->lineEdit->setText(record.name); | 23 | ui->lineEdit->setText(record.name); |
18 | ui->lineEdit->setFocus(); | 24 | ui->lineEdit->setFocus(); |
19 | ui->lineEdit->selectAll(); | 25 | ui->lineEdit->selectAll(); |
@@ -27,6 +33,20 @@ ProgrammingNamePopup::~ProgrammingNamePopup() | @@ -27,6 +33,20 @@ ProgrammingNamePopup::~ProgrammingNamePopup() | ||
27 | delete ui; | 33 | delete ui; |
28 | } | 34 | } |
29 | 35 | ||
36 | +bool ProgrammingNamePopup::eventFilter(QObject */*watched*/, QEvent *event) | ||
37 | +{ | ||
38 | + switch (event->type()) | ||
39 | + { | ||
40 | + case QEvent::FocusIn: | ||
41 | + lastLine = ui->lineEdit->text(); | ||
42 | + break; | ||
43 | + default: | ||
44 | + break; | ||
45 | + } | ||
46 | + | ||
47 | + return false; | ||
48 | +} | ||
49 | + | ||
30 | void ProgrammingNamePopup::keyPressEvent(QKeyEvent *event) | 50 | void ProgrammingNamePopup::keyPressEvent(QKeyEvent *event) |
31 | { | 51 | { |
32 | switch (event->key()) | 52 | switch (event->key()) |
@@ -62,6 +82,14 @@ void ProgrammingNamePopup::keyReleaseEvent(QKeyEvent *event) | @@ -62,6 +82,14 @@ void ProgrammingNamePopup::keyReleaseEvent(QKeyEvent *event) | ||
62 | } | 82 | } |
63 | } | 83 | } |
64 | 84 | ||
85 | +void ProgrammingNamePopup::revert() | ||
86 | +{ | ||
87 | + ui->lineEdit->setText(lastLine); | ||
88 | + | ||
89 | + if (focusWidget() == ui->lineEdit) | ||
90 | + ui->lineEdit->selectAll(); | ||
91 | +} | ||
92 | + | ||
65 | void ProgrammingNamePopup::on_okButton_clicked() | 93 | void ProgrammingNamePopup::on_okButton_clicked() |
66 | { | 94 | { |
67 | CookProgram::rename(record, ui->lineEdit->text()); | 95 | CookProgram::rename(record, ui->lineEdit->text()); |
@@ -78,15 +106,32 @@ void ProgrammingNamePopup::on_cancelButton_clicked() | @@ -78,15 +106,32 @@ void ProgrammingNamePopup::on_cancelButton_clicked() | ||
78 | 106 | ||
79 | void ProgrammingNamePopup::onEncoderLeft() | 107 | void ProgrammingNamePopup::onEncoderLeft() |
80 | { | 108 | { |
81 | - | 109 | + if (focusWidget() == ui->lineEdit) |
110 | + ui->cancelButton->setFocus(); | ||
111 | + else | ||
112 | + focusPreviousChild(); | ||
82 | } | 113 | } |
83 | 114 | ||
84 | void ProgrammingNamePopup::onEncoderRight() | 115 | void ProgrammingNamePopup::onEncoderRight() |
85 | { | 116 | { |
86 | - | 117 | + if (focusWidget() == ui->cancelButton) |
118 | + { | ||
119 | + ui->lineEdit->setFocus(); | ||
120 | + ui->lineEdit->selectAll(); | ||
121 | + } | ||
122 | + else | ||
123 | + focusNextChild(); | ||
87 | } | 124 | } |
88 | 125 | ||
89 | void ProgrammingNamePopup::onEncoderClicked(QWidget *clicked) | 126 | void ProgrammingNamePopup::onEncoderClicked(QWidget *clicked) |
90 | { | 127 | { |
91 | - | 128 | + QPushButton *b = qobject_cast<QPushButton *>(clicked); |
129 | + if (b) | ||
130 | + b->click(); | ||
131 | + else | ||
132 | + { | ||
133 | + QLineEdit *e = qobject_cast<QLineEdit *>(clicked); | ||
134 | + if (e) | ||
135 | + ui->keyboard->focusInKeyboard(); | ||
136 | + } | ||
92 | } | 137 | } |
app/gui/oven_control/programmingnamepopup.h
@@ -17,11 +17,15 @@ public: | @@ -17,11 +17,15 @@ public: | ||
17 | explicit ProgrammingNamePopup(QWidget *parent, CookRecord record); | 17 | explicit ProgrammingNamePopup(QWidget *parent, CookRecord record); |
18 | ~ProgrammingNamePopup(); | 18 | ~ProgrammingNamePopup(); |
19 | 19 | ||
20 | + bool eventFilter(QObject *watched, QEvent *event); | ||
21 | + | ||
20 | protected: | 22 | protected: |
21 | void keyPressEvent(QKeyEvent *event); | 23 | void keyPressEvent(QKeyEvent *event); |
22 | void keyReleaseEvent(QKeyEvent *event); | 24 | void keyReleaseEvent(QKeyEvent *event); |
23 | 25 | ||
24 | private slots: | 26 | private slots: |
27 | + void revert(); | ||
28 | + | ||
25 | void on_okButton_clicked(); | 29 | void on_okButton_clicked(); |
26 | 30 | ||
27 | void on_cancelButton_clicked(); | 31 | void on_cancelButton_clicked(); |
@@ -37,6 +41,8 @@ private: | @@ -37,6 +41,8 @@ private: | ||
37 | void onEncoderRight(); | 41 | void onEncoderRight(); |
38 | void onEncoderClicked(QWidget *clicked); | 42 | void onEncoderClicked(QWidget *clicked); |
39 | 43 | ||
44 | + QString lastLine; | ||
45 | + | ||
40 | signals: | 46 | signals: |
41 | void changed(); | 47 | void changed(); |
42 | }; | 48 | }; |
app/gui/oven_control/programmingnamepopup.ui
@@ -165,6 +165,11 @@ QPushButton:pressed, QPushButton:focus { color: yellow; }</string> | @@ -165,6 +165,11 @@ QPushButton:pressed, QPushButton:focus { color: yellow; }</string> | ||
165 | <container>1</container> | 165 | <container>1</container> |
166 | </customwidget> | 166 | </customwidget> |
167 | </customwidgets> | 167 | </customwidgets> |
168 | + <tabstops> | ||
169 | + <tabstop>lineEdit</tabstop> | ||
170 | + <tabstop>okButton</tabstop> | ||
171 | + <tabstop>cancelButton</tabstop> | ||
172 | + </tabstops> | ||
168 | <resources/> | 173 | <resources/> |
169 | <connections/> | 174 | <connections/> |
170 | </ui> | 175 | </ui> |
app/gui/oven_control/reservedtimepopup.cpp
@@ -2,6 +2,7 @@ | @@ -2,6 +2,7 @@ | ||
2 | #include "ui_reservedtimepopup.h" | 2 | #include "ui_reservedtimepopup.h" |
3 | 3 | ||
4 | #include <QDebug> | 4 | #include <QDebug> |
5 | +#include <QKeyEvent> | ||
5 | 6 | ||
6 | #include "stringer.h" | 7 | #include "stringer.h" |
7 | 8 | ||
@@ -18,6 +19,8 @@ ReservedTimePopup::ReservedTimePopup(QWidget *parent, QDateTime target) : | @@ -18,6 +19,8 @@ ReservedTimePopup::ReservedTimePopup(QWidget *parent, QDateTime target) : | ||
18 | checkTimeTimer.start(100); | 19 | checkTimeTimer.start(100); |
19 | 20 | ||
20 | checkTime(); | 21 | checkTime(); |
22 | + | ||
23 | + setFocus(); | ||
21 | } | 24 | } |
22 | 25 | ||
23 | ReservedTimePopup::~ReservedTimePopup() | 26 | ReservedTimePopup::~ReservedTimePopup() |
@@ -25,6 +28,37 @@ ReservedTimePopup::~ReservedTimePopup() | @@ -25,6 +28,37 @@ ReservedTimePopup::~ReservedTimePopup() | ||
25 | delete ui; | 28 | delete ui; |
26 | } | 29 | } |
27 | 30 | ||
31 | +void ReservedTimePopup::keyPressEvent(QKeyEvent *event) | ||
32 | +{ | ||
33 | + switch (event->key()) | ||
34 | + { | ||
35 | + case 0x01000030: // Turn left | ||
36 | + ui->cancelButton->setFocus(); | ||
37 | + break; | ||
38 | + case 0x01000031: // Push | ||
39 | + break; | ||
40 | + case 0x01000032: // Turn right | ||
41 | + ui->cancelButton->setFocus(); | ||
42 | + break; | ||
43 | + } | ||
44 | +} | ||
45 | + | ||
46 | +void ReservedTimePopup::keyReleaseEvent(QKeyEvent *event) | ||
47 | +{ | ||
48 | + switch (event->key()) | ||
49 | + { | ||
50 | + case 0x01000030: // Turn left | ||
51 | + ui->cancelButton->setFocus(); | ||
52 | + break; | ||
53 | + case 0x01000031: // Push | ||
54 | + ui->cancelButton->click(); | ||
55 | + break; | ||
56 | + case 0x01000032: // Turn right | ||
57 | + ui->cancelButton->setFocus(); | ||
58 | + break; | ||
59 | + } | ||
60 | +} | ||
61 | + | ||
28 | void ReservedTimePopup::checkTime() | 62 | void ReservedTimePopup::checkTime() |
29 | { | 63 | { |
30 | qint64 remaining = QDateTime::currentDateTime().msecsTo(target); | 64 | qint64 remaining = QDateTime::currentDateTime().msecsTo(target); |
@@ -39,6 +73,10 @@ void ReservedTimePopup::checkTime() | @@ -39,6 +73,10 @@ void ReservedTimePopup::checkTime() | ||
39 | 73 | ||
40 | void ReservedTimePopup::on_cancelButton_clicked() | 74 | void ReservedTimePopup::on_cancelButton_clicked() |
41 | { | 75 | { |
76 | + QWidget *focused = focusWidget(); | ||
77 | + if (focused) | ||
78 | + focused->clearFocus(); | ||
79 | + | ||
42 | emit canceled(); | 80 | emit canceled(); |
43 | close(); | 81 | close(); |
44 | } | 82 | } |
app/gui/oven_control/reservedtimepopup.h
@@ -17,6 +17,10 @@ public: | @@ -17,6 +17,10 @@ public: | ||
17 | explicit ReservedTimePopup(QWidget *parent, QDateTime target); | 17 | explicit ReservedTimePopup(QWidget *parent, QDateTime target); |
18 | ~ReservedTimePopup(); | 18 | ~ReservedTimePopup(); |
19 | 19 | ||
20 | +protected: | ||
21 | + void keyPressEvent(QKeyEvent* event); | ||
22 | + void keyReleaseEvent(QKeyEvent* event); | ||
23 | + | ||
20 | private: | 24 | private: |
21 | Ui::ReservedTimePopup *ui; | 25 | Ui::ReservedTimePopup *ui; |
22 | QDateTime target; | 26 | QDateTime target; |
app/gui/oven_control/reservetimepopup.cpp
@@ -2,8 +2,11 @@ | @@ -2,8 +2,11 @@ | ||
2 | #include "ui_reservetimepopup.h" | 2 | #include "ui_reservetimepopup.h" |
3 | 3 | ||
4 | #include <QDateTime> | 4 | #include <QDateTime> |
5 | +#include <QKeyEvent> | ||
6 | +#include <QDebug> | ||
5 | 7 | ||
6 | #include "reservedtimepopup.h" | 8 | #include "reservedtimepopup.h" |
9 | +#include "formatterspinbox.h" | ||
7 | 10 | ||
8 | ReserveTimePopup::ReserveTimePopup(QWidget *parent) : | 11 | ReserveTimePopup::ReserveTimePopup(QWidget *parent) : |
9 | QWidget(parent), | 12 | QWidget(parent), |
@@ -18,6 +21,16 @@ ReserveTimePopup::ReserveTimePopup(QWidget *parent) : | @@ -18,6 +21,16 @@ ReserveTimePopup::ReserveTimePopup(QWidget *parent) : | ||
18 | ui->day->setValue(dt.date().day()); | 21 | ui->day->setValue(dt.date().day()); |
19 | ui->hour->setValue(dt.time().hour()); | 22 | ui->hour->setValue(dt.time().hour()); |
20 | ui->min->setValue(dt.time().minute()); | 23 | ui->min->setValue(dt.time().minute()); |
24 | + | ||
25 | + connect(ui->keyboard, SIGNAL(onOkKeyClicked()), ui->keyboard, SLOT(focusOutKeyboard())); | ||
26 | + connect(ui->keyboard, SIGNAL(onCancelKeyClicked()), ui->keyboard, SLOT(focusOutKeyboard())); | ||
27 | + connect(ui->keyboard, SIGNAL(onCancelKeyClicked()), SLOT(revert())); | ||
28 | + | ||
29 | + foreach (FormatterSpinBox *b, findChildren<FormatterSpinBox *>()) | ||
30 | + b->installEventFilter(this); | ||
31 | + | ||
32 | + ui->min->setFocus(); | ||
33 | + ui->min->selectAll(); | ||
21 | } | 34 | } |
22 | 35 | ||
23 | ReserveTimePopup::~ReserveTimePopup() | 36 | ReserveTimePopup::~ReserveTimePopup() |
@@ -25,6 +38,68 @@ ReserveTimePopup::~ReserveTimePopup() | @@ -25,6 +38,68 @@ ReserveTimePopup::~ReserveTimePopup() | ||
25 | delete ui; | 38 | delete ui; |
26 | } | 39 | } |
27 | 40 | ||
41 | +bool ReserveTimePopup::eventFilter(QObject *watched, QEvent *event) | ||
42 | +{ | ||
43 | + FormatterSpinBox *e = qobject_cast<FormatterSpinBox *>(watched); | ||
44 | + if (e) | ||
45 | + { | ||
46 | + switch (event->type()) | ||
47 | + { | ||
48 | + case QEvent::FocusIn: | ||
49 | + lastValue = e->value(); | ||
50 | + break; | ||
51 | + default: | ||
52 | + break; | ||
53 | + } | ||
54 | + } | ||
55 | + | ||
56 | + return false; | ||
57 | +} | ||
58 | + | ||
59 | +void ReserveTimePopup::keyPressEvent(QKeyEvent *event) | ||
60 | +{ | ||
61 | + switch (event->key()) | ||
62 | + { | ||
63 | + case 0x01000030: // Turn left | ||
64 | + onEncoderLeft(); | ||
65 | + break; | ||
66 | + case 0x01000031: // Push | ||
67 | + pushed = focusWidget(); | ||
68 | + break; | ||
69 | + case 0x01000032: // Turn right | ||
70 | + onEncoderRight(); | ||
71 | + break; | ||
72 | + } | ||
73 | +} | ||
74 | + | ||
75 | +void ReserveTimePopup::keyReleaseEvent(QKeyEvent *event) | ||
76 | +{ | ||
77 | + switch (event->key()) | ||
78 | + { | ||
79 | + case 0x01000030: // Turn left | ||
80 | + onEncoderLeft(); | ||
81 | + break; | ||
82 | + case 0x01000031: // Push | ||
83 | + if (focusWidget() == pushed) | ||
84 | + onEncoderClicked(pushed); | ||
85 | + | ||
86 | + pushed = NULL; | ||
87 | + break; | ||
88 | + case 0x01000032: // Turn right | ||
89 | + onEncoderRight(); | ||
90 | + break; | ||
91 | + } | ||
92 | +} | ||
93 | + | ||
94 | +void ReserveTimePopup::revert() | ||
95 | +{ | ||
96 | + FormatterSpinBox *b = qobject_cast<FormatterSpinBox *>(focusWidget()); | ||
97 | + if (b) | ||
98 | + b->setValue(lastValue); | ||
99 | + | ||
100 | + qDebug() << lastValue; | ||
101 | +} | ||
102 | + | ||
28 | void ReserveTimePopup::on_okButton_clicked() | 103 | void ReserveTimePopup::on_okButton_clicked() |
29 | { | 104 | { |
30 | QDateTime current = QDateTime::currentDateTime(); | 105 | QDateTime current = QDateTime::currentDateTime(); |
@@ -49,3 +124,38 @@ void ReserveTimePopup::on_cancelButton_clicked() | @@ -49,3 +124,38 @@ void ReserveTimePopup::on_cancelButton_clicked() | ||
49 | emit canceled(); | 124 | emit canceled(); |
50 | close(); | 125 | close(); |
51 | } | 126 | } |
127 | + | ||
128 | +void ReserveTimePopup::onEncoderLeft() | ||
129 | +{ | ||
130 | + if (focusWidget() == ui->month) | ||
131 | + ui->cancelButton->setFocus(); | ||
132 | + else | ||
133 | + focusPreviousChild(); | ||
134 | +} | ||
135 | + | ||
136 | +void ReserveTimePopup::onEncoderRight() | ||
137 | +{ | ||
138 | + if (focusWidget() == ui->cancelButton) | ||
139 | + { | ||
140 | + ui->month->setFocus(); | ||
141 | + ui->month->selectAll(); | ||
142 | + } | ||
143 | + else | ||
144 | + focusNextChild(); | ||
145 | +} | ||
146 | + | ||
147 | +void ReserveTimePopup::onEncoderClicked(QWidget *clicked) | ||
148 | +{ | ||
149 | + QPushButton *b = qobject_cast<QPushButton *>(clicked); | ||
150 | + if (b) | ||
151 | + b->click(); | ||
152 | + else | ||
153 | + { | ||
154 | + FormatterSpinBox *e = qobject_cast<FormatterSpinBox *>(clicked); | ||
155 | + if (e) | ||
156 | + { | ||
157 | + qDebug() << "focusinkeyboard"; | ||
158 | + ui->keyboard->focusInKeyboard(); | ||
159 | + } | ||
160 | + } | ||
161 | +} |
app/gui/oven_control/reservetimepopup.h
@@ -15,7 +15,15 @@ public: | @@ -15,7 +15,15 @@ public: | ||
15 | explicit ReserveTimePopup(QWidget *parent = 0); | 15 | explicit ReserveTimePopup(QWidget *parent = 0); |
16 | ~ReserveTimePopup(); | 16 | ~ReserveTimePopup(); |
17 | 17 | ||
18 | + bool eventFilter(QObject *watched, QEvent *event); | ||
19 | + | ||
20 | +protected: | ||
21 | + void keyPressEvent(QKeyEvent* event); | ||
22 | + void keyReleaseEvent(QKeyEvent* event); | ||
23 | + | ||
18 | private slots: | 24 | private slots: |
25 | + void revert(); | ||
26 | + | ||
19 | void on_okButton_clicked(); | 27 | void on_okButton_clicked(); |
20 | 28 | ||
21 | void on_cancelButton_clicked(); | 29 | void on_cancelButton_clicked(); |
@@ -23,6 +31,14 @@ private slots: | @@ -23,6 +31,14 @@ private slots: | ||
23 | private: | 31 | private: |
24 | Ui::ReserveTimePopup *ui; | 32 | Ui::ReserveTimePopup *ui; |
25 | 33 | ||
34 | + int lastValue; | ||
35 | + | ||
36 | + QWidget *pushed = NULL; | ||
37 | + | ||
38 | + void onEncoderLeft(); | ||
39 | + void onEncoderRight(); | ||
40 | + void onEncoderClicked(QWidget *clicked); | ||
41 | + | ||
26 | signals: | 42 | signals: |
27 | void timeout(); | 43 | void timeout(); |
28 | void canceled(); | 44 | void canceled(); |
app/gui/oven_control/reservetimepopup.ui
@@ -426,6 +426,14 @@ QSpinBox{ | @@ -426,6 +426,14 @@ QSpinBox{ | ||
426 | <header>formatterspinbox.h</header> | 426 | <header>formatterspinbox.h</header> |
427 | </customwidget> | 427 | </customwidget> |
428 | </customwidgets> | 428 | </customwidgets> |
429 | + <tabstops> | ||
430 | + <tabstop>month</tabstop> | ||
431 | + <tabstop>day</tabstop> | ||
432 | + <tabstop>hour</tabstop> | ||
433 | + <tabstop>min</tabstop> | ||
434 | + <tabstop>okButton</tabstop> | ||
435 | + <tabstop>cancelButton</tabstop> | ||
436 | + </tabstops> | ||
429 | <resources/> | 437 | <resources/> |
430 | <connections/> | 438 | <connections/> |
431 | </ui> | 439 | </ui> |