Commit a2de3cbfc9877b689d067ec74c67d58e1895294a
1 parent
39aeb7f29f
Exists in
master
and in
2 other branches
수동 요리에 새 슬라이더 적용
Showing
10 changed files
with
250 additions
and
193 deletions
Show diff stats
app/gui/oven_control/cooldownpopup.cpp
... | ... | @@ -28,6 +28,9 @@ CooldownPopup::CooldownPopup(QWidget *parent, Oven *oven) : |
28 | 28 | ui->openDoorAnimation->load(":/images/animation/door_big_09.png"); |
29 | 29 | ui->openDoorAnimation->start(300); |
30 | 30 | |
31 | + ui->tempSlider->setSubPixmap(":/images/slider/sub_red.png"); | |
32 | + ui->tempSlider->setRange(30, 300); | |
33 | + | |
31 | 34 | cookingFanLevel = oven->fan(); |
32 | 35 | expectingFanLevel = oven->maxFan(); |
33 | 36 | started = false; |
... | ... | @@ -46,7 +49,7 @@ CooldownPopup::CooldownPopup(QWidget *parent, Oven *oven) : |
46 | 49 | checkOvenTimer.setInterval(100); |
47 | 50 | connect(&checkOvenTimer, SIGNAL(timeout()), SLOT(checkOven())); |
48 | 51 | |
49 | - connect(ui->tempSlider, SIGNAL(valueChanged(int)), SLOT(updateView())); | |
52 | + connect(ui->tempSlider, SIGNAL(sliderMoved(int)), SLOT(updateView())); | |
50 | 53 | |
51 | 54 | updateView(); |
52 | 55 | |
... | ... | @@ -92,6 +95,8 @@ void CooldownPopup::updateView() |
92 | 95 | int temp; |
93 | 96 | if (showingCurrentTemp) |
94 | 97 | temp = oven->currentTemp(); |
98 | + else if (ui->tempSlider->isSliderDown()) | |
99 | + temp = ui->tempSlider->sliderPosition(); | |
95 | 100 | else |
96 | 101 | temp = ui->tempSlider->value(); |
97 | 102 | ... | ... |
app/gui/oven_control/cooldownpopup.ui
... | ... | @@ -279,34 +279,6 @@ QPushButton:pressed { background-image: url(:/images/cooldown/side_nozzle_ov.png |
279 | 279 | <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set> |
280 | 280 | </property> |
281 | 281 | </widget> |
282 | - <widget class="QSlider" name="tempSlider"> | |
283 | - <property name="geometry"> | |
284 | - <rect> | |
285 | - <x>196</x> | |
286 | - <y>103</y> | |
287 | - <width>666</width> | |
288 | - <height>33</height> | |
289 | - </rect> | |
290 | - </property> | |
291 | - <property name="minimum"> | |
292 | - <number>30</number> | |
293 | - </property> | |
294 | - <property name="maximum"> | |
295 | - <number>300</number> | |
296 | - </property> | |
297 | - <property name="pageStep"> | |
298 | - <number>10</number> | |
299 | - </property> | |
300 | - <property name="tracking"> | |
301 | - <bool>true</bool> | |
302 | - </property> | |
303 | - <property name="orientation"> | |
304 | - <enum>Qt::Horizontal</enum> | |
305 | - </property> | |
306 | - <property name="sliderColor" stdset="0"> | |
307 | - <string>red</string> | |
308 | - </property> | |
309 | - </widget> | |
310 | 282 | <widget class="QLabel" name="tempCurrentLabel"> |
311 | 283 | <property name="enabled"> |
312 | 284 | <bool>true</bool> |
... | ... | @@ -371,6 +343,16 @@ QPushButton:pressed { background-image: url(:/images/cooldown/side_nozzle_ov.png |
371 | 343 | <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> |
372 | 344 | </property> |
373 | 345 | </widget> |
346 | + <widget class="Slider" name="tempSlider" native="true"> | |
347 | + <property name="geometry"> | |
348 | + <rect> | |
349 | + <x>196</x> | |
350 | + <y>50</y> | |
351 | + <width>666</width> | |
352 | + <height>140</height> | |
353 | + </rect> | |
354 | + </property> | |
355 | + </widget> | |
374 | 356 | </widget> |
375 | 357 | <widget class="QPushButton" name="closeButton"> |
376 | 358 | <property name="geometry"> |
... | ... | @@ -434,6 +416,12 @@ QPushButton:pressed { background-image: url(:/images/cooldown/side_nozzle_ov.png |
434 | 416 | <extends>QLabel</extends> |
435 | 417 | <header>animatedimagebox.h</header> |
436 | 418 | </customwidget> |
419 | + <customwidget> | |
420 | + <class>Slider</class> | |
421 | + <extends>QWidget</extends> | |
422 | + <header>slider.h</header> | |
423 | + <container>1</container> | |
424 | + </customwidget> | |
437 | 425 | </customwidgets> |
438 | 426 | <resources> |
439 | 427 | <include location="resources.qrc"/> | ... | ... |
app/gui/oven_control/coretempsettingpopup.cpp
... | ... | @@ -39,7 +39,20 @@ CoreTempSettingPopup::CoreTempSettingPopup(QWidget *parent) : |
39 | 39 | oven = Oven::getInstance(); |
40 | 40 | connect(oven, SIGNAL(changed(Oven*)), SLOT(updateView())); |
41 | 41 | |
42 | + ui->coreTempSlider->setSubPixmap(":/images/slider/core.png"); | |
42 | 43 | ui->coreTempSlider->setRange(oven->minInterTemp(), oven->maxInterTemp()); |
44 | + | |
45 | + QList<int> &bigTicks = ui->coreTempSlider->bigTicks; | |
46 | + bigTicks.append(oven->minInterTemp()); | |
47 | + bigTicks.append(oven->minInterTemp() + (oven->maxInterTemp() - oven->minInterTemp()) / 2); | |
48 | + bigTicks.append(oven->maxInterTemp()); | |
49 | + | |
50 | + QList<int> &ticks = ui->coreTempSlider->ticks; | |
51 | + for (int i = 1; i < 3; i++) | |
52 | + ticks.append(bigTicks.at(0) + i * (bigTicks.at(1) - bigTicks.at(0)) / 3); | |
53 | + for (int i = 1; i < 3; i++) | |
54 | + ticks.append(bigTicks.at(1) + i * (bigTicks.at(2) - bigTicks.at(1)) / 3); | |
55 | + | |
43 | 56 | ui->coreTempSlider->setValue(oven->interTemp()); |
44 | 57 | |
45 | 58 | connect(ui->coreTempSlider, SIGNAL(sliderMoved(int)), SLOT(updateView())); | ... | ... |
app/gui/oven_control/coretempsettingpopup.ui
... | ... | @@ -507,31 +507,6 @@ QPushButton:pressed { image: url(:/images/slider_icon/core_temp_ov.png); }</stri |
507 | 507 | <set>Qt::AlignCenter</set> |
508 | 508 | </property> |
509 | 509 | </widget> |
510 | - <widget class="QSlider" name="coreTempSlider"> | |
511 | - <property name="geometry"> | |
512 | - <rect> | |
513 | - <x>185</x> | |
514 | - <y>1012</y> | |
515 | - <width>666</width> | |
516 | - <height>33</height> | |
517 | - </rect> | |
518 | - </property> | |
519 | - <property name="styleSheet"> | |
520 | - <string notr="true">QSlider::sub-page { background-image: url(:/images/slider/core.png); }</string> | |
521 | - </property> | |
522 | - <property name="maximum"> | |
523 | - <number>6</number> | |
524 | - </property> | |
525 | - <property name="value"> | |
526 | - <number>0</number> | |
527 | - </property> | |
528 | - <property name="tracking"> | |
529 | - <bool>true</bool> | |
530 | - </property> | |
531 | - <property name="orientation"> | |
532 | - <enum>Qt::Horizontal</enum> | |
533 | - </property> | |
534 | - </widget> | |
535 | 510 | <widget class="QLabel" name="curCoreTempLabel"> |
536 | 511 | <property name="enabled"> |
537 | 512 | <bool>true</bool> |
... | ... | @@ -1020,7 +995,25 @@ QPushButton:pressed { background-image: url(:/images/manual_button/back_ov.png); |
1020 | 995 | <set>Qt::AlignBottom|Qt::AlignHCenter</set> |
1021 | 996 | </property> |
1022 | 997 | </widget> |
998 | + <widget class="Slider" name="coreTempSlider" native="true"> | |
999 | + <property name="geometry"> | |
1000 | + <rect> | |
1001 | + <x>185</x> | |
1002 | + <y>954</y> | |
1003 | + <width>666</width> | |
1004 | + <height>140</height> | |
1005 | + </rect> | |
1006 | + </property> | |
1007 | + </widget> | |
1023 | 1008 | </widget> |
1009 | + <customwidgets> | |
1010 | + <customwidget> | |
1011 | + <class>Slider</class> | |
1012 | + <extends>QWidget</extends> | |
1013 | + <header>slider.h</header> | |
1014 | + <container>1</container> | |
1015 | + </customwidget> | |
1016 | + </customwidgets> | |
1024 | 1017 | <resources> |
1025 | 1018 | <include location="resources.qrc"/> |
1026 | 1019 | </resources> | ... | ... |
app/gui/oven_control/main.cpp
... | ... | @@ -22,6 +22,8 @@ int main(int argc, char *argv[]) |
22 | 22 | OvenStatistics::getInstance(oven); |
23 | 23 | Config::getInstance(oven); |
24 | 24 | |
25 | + oven->setDefault(Define::CombiMode); | |
26 | + | |
25 | 27 | // QTranslator* trans = new QTranslator(); |
26 | 28 | // qDebug() << trans->load(":/lang_en.qm"); |
27 | 29 | // QApplication::installTranslator(trans); | ... | ... |
app/gui/oven_control/manualcookwindow.cpp
... | ... | @@ -35,9 +35,44 @@ ManualCookWindow::ManualCookWindow(QWidget *parent, Define::Mode mode) : |
35 | 35 | ui->closeDoorWidget->setParent(ui->upperStack); |
36 | 36 | setAttribute(Qt::WA_DeleteOnClose); |
37 | 37 | |
38 | - | |
39 | 38 | oven = Oven::getInstance(); |
40 | 39 | |
40 | + ui->humiditySlider->setSubPixmap(":/images/slider/humidity.png"); | |
41 | + ui->humiditySlider->setRange(0, 100); | |
42 | + ui->humiditySlider->bigTickInterval = 50; | |
43 | + ui->humiditySlider->tickInterval = 10; | |
44 | + | |
45 | + ui->tempSlider->setSubPixmap(":/images/slider/temp.png"); | |
46 | + ui->tempSlider->bigTickInterval = 50; | |
47 | + ui->tempSlider->tickInterval = 10; | |
48 | + | |
49 | + ui->timeSlider->setSubPixmap(":/images/slider/time.png"); | |
50 | + ui->timeSlider->setRange(0, 342); | |
51 | + ui->timeSlider->bigTicks.append(0); | |
52 | + ui->timeSlider->bigTicks.append(180); | |
53 | + ui->timeSlider->bigTicks.append(270); | |
54 | + ui->timeSlider->bigTicks.append(342); | |
55 | + ui->timeSlider->ticks.append(60); | |
56 | + ui->timeSlider->ticks.append(120); | |
57 | + ui->timeSlider->ticks.append(180 + 30); | |
58 | + ui->timeSlider->ticks.append(180 + 60); | |
59 | + ui->timeSlider->ticks.append(270 + 4 * 6); | |
60 | + ui->timeSlider->ticks.append(270 + 4 * 12); | |
61 | + | |
62 | + ui->interTempSlider->setSubPixmap(":/images/slider/core.png"); | |
63 | + | |
64 | + QList<int> &bigTicks = ui->interTempSlider->bigTicks; | |
65 | + bigTicks.append(oven->minInterTemp()); | |
66 | + bigTicks.append(oven->minInterTemp() + (oven->maxInterTemp() - oven->minInterTemp()) / 2); | |
67 | + bigTicks.append(oven->maxInterTemp()); | |
68 | + | |
69 | + QList<int> &ticks = ui->interTempSlider->ticks; | |
70 | + for (int i = 1; i < 3; i++) | |
71 | + ticks.append(bigTicks.at(0) + i * (bigTicks.at(1) - bigTicks.at(0)) / 3); | |
72 | + for (int i = 1; i < 3; i++) | |
73 | + ticks.append(bigTicks.at(1) + i * (bigTicks.at(2) - bigTicks.at(1)) / 3); | |
74 | + | |
75 | + | |
41 | 76 | lastViewHumidity = -1; |
42 | 77 | lastViewTemp = -1; |
43 | 78 | lastViewTime = -1; |
... | ... | @@ -67,11 +102,8 @@ ManualCookWindow::ManualCookWindow(QWidget *parent, Define::Mode mode) : |
67 | 102 | else |
68 | 103 | monitorLevel = 0; |
69 | 104 | |
70 | - connect(oven, SIGNAL(changed(Oven*)), this, SLOT(onOvenUpdated(Oven*))); | |
71 | - | |
72 | 105 | connect(ui->humiditySlider, SIGNAL(valueChanged(int)), oven, SLOT(setHumidity(int))); |
73 | 106 | connect(ui->tempSlider, SIGNAL(valueChanged(int)), oven, SLOT(setTemp(int))); |
74 | - connect(ui->timeSlider, SIGNAL(valueChanged(int)), oven, SLOT(setTime(int))); | |
75 | 107 | connect(ui->timeSlider, SIGNAL(valueChanged(int)), &startCookingTimer, SLOT(start())); |
76 | 108 | connect(ui->timeSlider, SIGNAL(valueChanged(int)), this, SLOT(updateView())); |
77 | 109 | connect(ui->interTempSlider, SIGNAL(valueChanged(int)), oven, SLOT(setInterTemp(int))); |
... | ... | @@ -93,6 +125,7 @@ ManualCookWindow::ManualCookWindow(QWidget *parent, Define::Mode mode) : |
93 | 125 | showCurrentTempTimer.setInterval(2000); |
94 | 126 | connect(&showCurrentTempTimer, SIGNAL(timeout()), SLOT(showCurrentTemp())); |
95 | 127 | |
128 | + connect(oven, SIGNAL(changed(Oven*)), this, SLOT(onOvenUpdated(Oven*))); | |
96 | 129 | oven->setDefault(mode); |
97 | 130 | |
98 | 131 | connect(&updateViewTimer, SIGNAL(timeout()), SLOT(updateView())); |
... | ... | @@ -193,18 +226,18 @@ void ManualCookWindow::updateView() |
193 | 226 | { |
194 | 227 | lastViewTemp = temp; |
195 | 228 | |
196 | - bool old = ui->tempSlider->blockSignals(true); | |
197 | - ui->tempSlider->setRange(oven->minTemp(), oven->maxTemp()); | |
198 | - if (ui->tempSlider->sliderPosition() != temp) | |
199 | - ui->tempSlider->setValue(temp); | |
200 | - ui->tempSlider->blockSignals(old); | |
201 | - | |
202 | 229 | ui->tempLabel->setText(Stringer::temperature(temp, Stringer::fontSize14)); |
203 | 230 | } |
204 | 231 | |
232 | + bool old = ui->tempSlider->blockSignals(true); | |
233 | + ui->tempSlider->setRange(oven->minTemp(), oven->maxTemp()); | |
234 | + if (ui->tempSlider->sliderPosition() != temp) | |
235 | + ui->tempSlider->setValue(temp); | |
236 | + ui->tempSlider->blockSignals(old); | |
237 | + | |
205 | 238 | int msecs; |
206 | 239 | if (ui->timeSlider->isSliderDown()) |
207 | - msecs = ui->timeSlider->sliderPosition() * 1000; | |
240 | + msecs = sliderToTime(ui->timeSlider->sliderPosition()) * 1000; | |
208 | 241 | else |
209 | 242 | msecs = oven->msecs(); |
210 | 243 | |
... | ... | @@ -213,7 +246,7 @@ void ManualCookWindow::updateView() |
213 | 246 | lastViewTime = msecs; |
214 | 247 | |
215 | 248 | bool old = ui->timeSlider->blockSignals(true); |
216 | - ui->timeSlider->setSliderPosition(msecs / 1000); | |
249 | + ui->timeSlider->setSliderPosition(timeToSlider(msecs / 1000)); | |
217 | 250 | ui->timeSlider->blockSignals(old); |
218 | 251 | |
219 | 252 | ui->timeLabel->setText(Stringer::remainingTime(msecs, Stringer::fontSize14)); |
... | ... | @@ -254,8 +287,10 @@ QPushButton:pressed {\ |
254 | 287 | |
255 | 288 | bool old = ui->interTempSlider->blockSignals(true); |
256 | 289 | ui->interTempSlider->setEnabled(interTempEnabled); |
290 | + ui->interTempSlider->setSubVisible(interTempEnabled); | |
257 | 291 | ui->interTempSlider->setRange(oven->minInterTemp(), oven->maxInterTemp()); |
258 | - ui->interTempSlider->setValue(interTemp); | |
292 | + if (ui->interTempSlider->sliderPosition() != interTemp) | |
293 | + ui->interTempSlider->setValue(interTemp); | |
259 | 294 | ui->interTempSlider->blockSignals(old); |
260 | 295 | |
261 | 296 | if (interTempEnabled) |
... | ... | @@ -791,3 +826,26 @@ void ManualCookWindow::on_helpButton_clicked() |
791 | 826 | { |
792 | 827 | |
793 | 828 | } |
829 | + | |
830 | +void ManualCookWindow::on_timeSlider_valueChanged() | |
831 | +{ | |
832 | + oven->setTime(sliderToTime(ui->timeSlider->value())); | |
833 | +} | |
834 | + | |
835 | +int ManualCookWindow::sliderToTime(int value) | |
836 | +{ | |
837 | + if (value <= 180) | |
838 | + return value * 60; | |
839 | + if (value <= 270) | |
840 | + return 180 * 60 + (value - 180) * 2 * 60; | |
841 | + return 360 * 60 + (value - 270) * 15 * 60; | |
842 | +} | |
843 | + | |
844 | +int ManualCookWindow::timeToSlider(int secs) | |
845 | +{ | |
846 | + if (secs <= 180 * 60) | |
847 | + return secs / 60; | |
848 | + if (secs <= 360 * 60) | |
849 | + return 180 + (secs - 180 * 60) / 2 / 60; | |
850 | + return 270 + (secs - 360 * 60) / 15 / 60; | |
851 | +} | ... | ... |
app/gui/oven_control/manualcookwindow.h
... | ... | @@ -75,6 +75,8 @@ private slots: |
75 | 75 | void on_washButton_clicked(); |
76 | 76 | void on_helpButton_clicked(); |
77 | 77 | |
78 | + void on_timeSlider_valueChanged(); | |
79 | + | |
78 | 80 | private: |
79 | 81 | Ui::ManualCookWindow *ui; |
80 | 82 | Oven *oven; |
... | ... | @@ -112,6 +114,9 @@ private: |
112 | 114 | |
113 | 115 | ManualCookSetting repeatSetting; |
114 | 116 | bool repeat; |
117 | + | |
118 | + int sliderToTime(int value); | |
119 | + int timeToSlider(int secs); | |
115 | 120 | }; |
116 | 121 | |
117 | 122 | #endif // MANUALCOOKWINDOW_H | ... | ... |
app/gui/oven_control/manualcookwindow.ui
... | ... | @@ -360,28 +360,6 @@ QPushButton:pressed { border-image: url(:/images/bottom_bar/help_ov.png); }</str |
360 | 360 | <set>Qt::AlignCenter</set> |
361 | 361 | </property> |
362 | 362 | </widget> |
363 | - <widget class="QSlider" name="humiditySlider"> | |
364 | - <property name="geometry"> | |
365 | - <rect> | |
366 | - <x>185</x> | |
367 | - <y>783</y> | |
368 | - <width>666</width> | |
369 | - <height>33</height> | |
370 | - </rect> | |
371 | - </property> | |
372 | - <property name="styleSheet"> | |
373 | - <string notr="true">QSlider::sub-page { background-image: url(:/images/slider/humidity.png); }</string> | |
374 | - </property> | |
375 | - <property name="maximum"> | |
376 | - <number>100</number> | |
377 | - </property> | |
378 | - <property name="tracking"> | |
379 | - <bool>false</bool> | |
380 | - </property> | |
381 | - <property name="orientation"> | |
382 | - <enum>Qt::Horizontal</enum> | |
383 | - </property> | |
384 | - </widget> | |
385 | 363 | <widget class="QLabel" name="steamLabel_2"> |
386 | 364 | <property name="enabled"> |
387 | 365 | <bool>true</bool> |
... | ... | @@ -589,61 +567,6 @@ QPushButton:pressed { image: url(:/images/slider_icon/temp_ov.png); }</string> |
589 | 567 | <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> |
590 | 568 | </property> |
591 | 569 | </widget> |
592 | - <widget class="QSlider" name="interTempSlider"> | |
593 | - <property name="enabled"> | |
594 | - <bool>false</bool> | |
595 | - </property> | |
596 | - <property name="geometry"> | |
597 | - <rect> | |
598 | - <x>185</x> | |
599 | - <y>1233</y> | |
600 | - <width>666</width> | |
601 | - <height>33</height> | |
602 | - </rect> | |
603 | - </property> | |
604 | - <property name="styleSheet"> | |
605 | - <string notr="true">QSlider::sub-page { background-image: url(:/images/slider/core.png); } | |
606 | -QSlider::sub-page:disabled { background: #00000000; } | |
607 | -QSlider::handle:disabled { background: #00000000; }</string> | |
608 | - </property> | |
609 | - <property name="maximum"> | |
610 | - <number>6</number> | |
611 | - </property> | |
612 | - <property name="value"> | |
613 | - <number>0</number> | |
614 | - </property> | |
615 | - <property name="tracking"> | |
616 | - <bool>false</bool> | |
617 | - </property> | |
618 | - <property name="orientation"> | |
619 | - <enum>Qt::Horizontal</enum> | |
620 | - </property> | |
621 | - </widget> | |
622 | - <widget class="QSlider" name="tempSlider"> | |
623 | - <property name="geometry"> | |
624 | - <rect> | |
625 | - <x>185</x> | |
626 | - <y>933</y> | |
627 | - <width>666</width> | |
628 | - <height>33</height> | |
629 | - </rect> | |
630 | - </property> | |
631 | - <property name="styleSheet"> | |
632 | - <string notr="true">QSlider::sub-page { background-image: url(:/images/slider/temp.png); }</string> | |
633 | - </property> | |
634 | - <property name="maximum"> | |
635 | - <number>6</number> | |
636 | - </property> | |
637 | - <property name="value"> | |
638 | - <number>0</number> | |
639 | - </property> | |
640 | - <property name="tracking"> | |
641 | - <bool>false</bool> | |
642 | - </property> | |
643 | - <property name="orientation"> | |
644 | - <enum>Qt::Horizontal</enum> | |
645 | - </property> | |
646 | - </widget> | |
647 | 570 | <widget class="QLabel" name="humidityLabel"> |
648 | 571 | <property name="enabled"> |
649 | 572 | <bool>true</bool> |
... | ... | @@ -708,37 +631,6 @@ QSlider::handle:disabled { background: #00000000; }</string> |
708 | 631 | <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> |
709 | 632 | </property> |
710 | 633 | </widget> |
711 | - <widget class="QSlider" name="timeSlider"> | |
712 | - <property name="geometry"> | |
713 | - <rect> | |
714 | - <x>185</x> | |
715 | - <y>1083</y> | |
716 | - <width>666</width> | |
717 | - <height>33</height> | |
718 | - </rect> | |
719 | - </property> | |
720 | - <property name="styleSheet"> | |
721 | - <string notr="true">QSlider::sub-page { background-image: url(:/images/slider/time.png); }</string> | |
722 | - </property> | |
723 | - <property name="maximum"> | |
724 | - <number>86400</number> | |
725 | - </property> | |
726 | - <property name="singleStep"> | |
727 | - <number>60</number> | |
728 | - </property> | |
729 | - <property name="pageStep"> | |
730 | - <number>3600</number> | |
731 | - </property> | |
732 | - <property name="value"> | |
733 | - <number>0</number> | |
734 | - </property> | |
735 | - <property name="tracking"> | |
736 | - <bool>false</bool> | |
737 | - </property> | |
738 | - <property name="orientation"> | |
739 | - <enum>Qt::Horizontal</enum> | |
740 | - </property> | |
741 | - </widget> | |
742 | 634 | <widget class="QStackedWidget" name="buttonStack"> |
743 | 635 | <property name="geometry"> |
744 | 636 | <rect> |
... | ... | @@ -1236,6 +1128,46 @@ QPushButton:pressed { image: url(:/images/slider_icon/time_ov.png); }</string> |
1236 | 1128 | <string/> |
1237 | 1129 | </property> |
1238 | 1130 | </widget> |
1131 | + <widget class="Slider" name="tempSlider" native="true"> | |
1132 | + <property name="geometry"> | |
1133 | + <rect> | |
1134 | + <x>185</x> | |
1135 | + <y>875</y> | |
1136 | + <width>666</width> | |
1137 | + <height>140</height> | |
1138 | + </rect> | |
1139 | + </property> | |
1140 | + </widget> | |
1141 | + <widget class="Slider" name="humiditySlider" native="true"> | |
1142 | + <property name="geometry"> | |
1143 | + <rect> | |
1144 | + <x>185</x> | |
1145 | + <y>725</y> | |
1146 | + <width>666</width> | |
1147 | + <height>140</height> | |
1148 | + </rect> | |
1149 | + </property> | |
1150 | + </widget> | |
1151 | + <widget class="Slider" name="timeSlider" native="true"> | |
1152 | + <property name="geometry"> | |
1153 | + <rect> | |
1154 | + <x>185</x> | |
1155 | + <y>1025</y> | |
1156 | + <width>666</width> | |
1157 | + <height>140</height> | |
1158 | + </rect> | |
1159 | + </property> | |
1160 | + </widget> | |
1161 | + <widget class="Slider" name="interTempSlider" native="true"> | |
1162 | + <property name="geometry"> | |
1163 | + <rect> | |
1164 | + <x>185</x> | |
1165 | + <y>1175</y> | |
1166 | + <width>666</width> | |
1167 | + <height>140</height> | |
1168 | + </rect> | |
1169 | + </property> | |
1170 | + </widget> | |
1239 | 1171 | </widget> |
1240 | 1172 | </widget> |
1241 | 1173 | <customwidgets> |
... | ... | @@ -1255,6 +1187,12 @@ QPushButton:pressed { image: url(:/images/slider_icon/time_ov.png); }</string> |
1255 | 1187 | <extends>QLabel</extends> |
1256 | 1188 | <header>animatedimagebox.h</header> |
1257 | 1189 | </customwidget> |
1190 | + <customwidget> | |
1191 | + <class>Slider</class> | |
1192 | + <extends>QWidget</extends> | |
1193 | + <header>slider.h</header> | |
1194 | + <container>1</container> | |
1195 | + </customwidget> | |
1258 | 1196 | </customwidgets> |
1259 | 1197 | <resources> |
1260 | 1198 | <include location="resources.qrc"/> | ... | ... |
app/gui/oven_control/slider.cpp
... | ... | @@ -5,13 +5,15 @@ |
5 | 5 | #include <QDebug> |
6 | 6 | |
7 | 7 | Slider::Slider(QWidget *parent) : QWidget(parent), |
8 | - isSliderDown_(false), sliderPosition_(0), value_(0), minimum_(0), maximum_(1) | |
8 | + isSliderDown_(false), | |
9 | + sliderPosition_(0), value_(0), minimum_(0), maximum_(1), | |
10 | + subVisible_(true), | |
11 | + tickInterval(0), bigTickInterval(0) | |
9 | 12 | { |
10 | 13 | groove.load(":/images/slider/groove.png"); |
11 | 14 | sub.load(":/images/slider/humidity.png"); |
12 | 15 | handle.load(":/images/slider/handle_big.png"); |
13 | 16 | updatePixmapPosition(); |
14 | - | |
15 | 17 | } |
16 | 18 | |
17 | 19 | void Slider::setSubPixmap(const QPixmap &pixmap) |
... | ... | @@ -24,8 +26,21 @@ void Slider::setSubPixmap(const QString &fileName) |
24 | 26 | setSubPixmap(QPixmap(fileName)); |
25 | 27 | } |
26 | 28 | |
29 | +void Slider::setSubVisible(bool visible) | |
30 | +{ | |
31 | + if (subVisible_ == visible) | |
32 | + return; | |
33 | + | |
34 | + subVisible_ = visible; | |
35 | + | |
36 | + update(); | |
37 | +} | |
38 | + | |
27 | 39 | void Slider::setRange(int min, int max) |
28 | 40 | { |
41 | + if (minimum_ == min && maximum_ == max) | |
42 | + return; | |
43 | + | |
29 | 44 | minimum_ = min; |
30 | 45 | maximum_ = max; |
31 | 46 | |
... | ... | @@ -33,22 +48,39 @@ void Slider::setRange(int min, int max) |
33 | 48 | setValue(min); |
34 | 49 | else if (value_ > max) |
35 | 50 | setValue(max); |
51 | + | |
52 | + update(); | |
36 | 53 | } |
37 | 54 | |
38 | 55 | void Slider::setMinimum(int min) |
39 | 56 | { |
57 | + if (minimum_ == min) | |
58 | + return; | |
59 | + | |
40 | 60 | minimum_ = min; |
41 | 61 | |
42 | 62 | if (value_ < min) |
43 | 63 | setValue(min); |
64 | + | |
65 | + update(); | |
44 | 66 | } |
45 | 67 | |
46 | 68 | void Slider::setMaximum(int max) |
47 | 69 | { |
70 | + if (maximum_ == max) | |
71 | + return; | |
72 | + | |
48 | 73 | maximum_ = max; |
49 | 74 | |
50 | 75 | if (value_ > max) |
51 | 76 | setValue(max); |
77 | + | |
78 | + update(); | |
79 | +} | |
80 | + | |
81 | +int Slider::value() | |
82 | +{ | |
83 | + return value_; | |
52 | 84 | } |
53 | 85 | |
54 | 86 | bool Slider::isSliderDown() |
... | ... | @@ -99,30 +131,47 @@ void Slider::mouseReleaseEvent(QMouseEvent */*event*/) |
99 | 131 | void Slider::paintEvent(QPaintEvent */*event*/) |
100 | 132 | { |
101 | 133 | QPainter painter(this); |
102 | - | |
103 | 134 | painter.drawPixmap(groovePoint, groove); |
104 | 135 | |
105 | - int subLength = calcSubLength(sliderPosition_); | |
106 | - if (subLength > 0) | |
107 | - painter.drawPixmap(subPoint, sub, QRect(0, 0, subLength, sub.height())); | |
108 | - | |
109 | 136 | QPen tickPen(QColor(71, 71, 71)); |
110 | 137 | tickPen.setWidth(2); |
111 | 138 | painter.setPen(tickPen); |
112 | - foreach (int tick, ticks) | |
113 | - { | |
114 | - int x = subPoint.x() + calcSubLength(tick); | |
115 | - painter.drawLine(x, groovePoint.y() + 22, x, groovePoint.y() + 28); | |
116 | - } | |
117 | 139 | |
118 | - foreach (int tick, bigTicks) | |
140 | + if (tickInterval) | |
141 | + for (int tick = minimum_; tick <= maximum_; tick += tickInterval) | |
142 | + { | |
143 | + int x = subPoint.x() + calcSubLength(tick); | |
144 | + painter.drawLine(x, groovePoint.y() + 22, x, groovePoint.y() + 28); | |
145 | + } | |
146 | + else | |
147 | + foreach (int tick, ticks) | |
148 | + { | |
149 | + int x = subPoint.x() + calcSubLength(tick); | |
150 | + painter.drawLine(x, groovePoint.y() + 22, x, groovePoint.y() + 28); | |
151 | + } | |
152 | + | |
153 | + if (bigTickInterval) | |
154 | + for (int tick = minimum_; tick <= maximum_; tick += bigTickInterval) | |
155 | + { | |
156 | + int x = subPoint.x() + calcSubLength(tick); | |
157 | + painter.drawLine(x, groovePoint.y() + 22, x, groovePoint.y() + 33); | |
158 | + } | |
159 | + else | |
160 | + foreach (int tick, bigTicks) | |
161 | + { | |
162 | + int x = subPoint.x() + calcSubLength(tick); | |
163 | + painter.drawLine(x, groovePoint.y() + 22, x, groovePoint.y() + 33); | |
164 | + } | |
165 | + | |
166 | + if (subVisible_) | |
119 | 167 | { |
120 | - int x = subPoint.x() + calcSubLength(tick); | |
121 | - painter.drawLine(x, groovePoint.y() + 22, x, groovePoint.y() + 33); | |
122 | - } | |
168 | + int subLength = calcSubLength(sliderPosition_); | |
169 | + if (subLength > 0) | |
170 | + painter.drawPixmap(subPoint, sub, QRect(0, 0, subLength, sub.height())); | |
123 | 171 | |
124 | - QPoint handlePoint(subPoint.x() + subLength - handle.width() / 2, (height() - handle.height()) / 2); | |
125 | - painter.drawPixmap(handlePoint, handle); | |
172 | + QPoint handlePoint(subPoint.x() + subLength - handle.width() / 2, (height() - handle.height()) / 2); | |
173 | + painter.drawPixmap(handlePoint, handle); | |
174 | + } | |
126 | 175 | } |
127 | 176 | |
128 | 177 | void Slider::resizeEvent(QResizeEvent */*event*/) | ... | ... |
app/gui/oven_control/slider.h
... | ... | @@ -24,11 +24,14 @@ class Slider : public QWidget |
24 | 24 | QPoint groovePoint; |
25 | 25 | QPoint subPoint; |
26 | 26 | |
27 | + bool subVisible_; | |
28 | + | |
27 | 29 | public: |
28 | 30 | explicit Slider(QWidget *parent = 0); |
29 | 31 | |
30 | 32 | void setSubPixmap(const QPixmap &pixmap); |
31 | 33 | void setSubPixmap(const QString &fileName); |
34 | + void setSubVisible(bool visible); | |
32 | 35 | |
33 | 36 | void setRange(int min, int max); |
34 | 37 | void setMinimum(int min); |
... | ... | @@ -45,6 +48,9 @@ public: |
45 | 48 | QList<int> ticks; |
46 | 49 | QList<int> bigTicks; |
47 | 50 | |
51 | + int tickInterval; | |
52 | + int bigTickInterval; | |
53 | + | |
48 | 54 | protected: |
49 | 55 | virtual void mouseMoveEvent(QMouseEvent *event); |
50 | 56 | virtual void mousePressEvent(QMouseEvent *event); | ... | ... |