#include "modelsettingwindow.h" #include "ui_modelsettingwindow.h" #include #include "electricmodelsettingwindow.h" #include "gasmodelsettingwindow.h" #include "soundplayer.h" ModelSettingWindow::ModelSettingWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::ModelSettingWindow) { ui->setupUi(this); ui->clockContainer->setParent(ui->upperStack); setAttribute(Qt::WA_DeleteOnClose); foreach (QPushButton *button, findChildren()) connect(button, &QPushButton::pressed, SoundPlayer::playClick); } ModelSettingWindow::~ModelSettingWindow() { delete ui; } void ModelSettingWindow::keyPressEvent(QKeyEvent *event) { switch (event->key()) { case 0x01000032: // Turn left onEncoderLeft(); break; case 0x01000031: // Push pushed = focusWidget(); break; case 0x01000030: // Turn right onEncoderRight(); break; } } void ModelSettingWindow::keyReleaseEvent(QKeyEvent *event) { switch (event->key()) { case 0x01000032: // Turn left onEncoderLeft(); break; case 0x01000031: // Push if (focusWidget() == pushed) onEncoderClicked(pushed); pushed = NULL; break; case 0x01000030: // Turn right onEncoderRight(); break; } } void ModelSettingWindow::on_electricButton_clicked() { ElectricModelSettingWindow *w = new ElectricModelSettingWindow(this); w->showFullScreen(); } void ModelSettingWindow::on_gasButton_clicked() { GasModelSettingWindow *w = new GasModelSettingWindow(this); w->showFullScreen(); } void ModelSettingWindow::on_backButton_clicked() { close(); } void ModelSettingWindow::onEncoderLeft() { focusPreviousChild(); } void ModelSettingWindow::onEncoderRight() { focusNextChild(); } void ModelSettingWindow::onEncoderClicked(QWidget *clicked) { QPushButton *b = qobject_cast(clicked); if (b) b->click(); }