adjustmentwindow.cpp 1.69 KB
#include <qdebug.h>
#include "adjustmentwindow.h"
#include "ui_adjustmentwindow.h"
#include "yesnopopupdlg.h"
#include "soundplayer.h"

AdjustmentWindow::AdjustmentWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::AdjustmentWindow)
{
    ui->setupUi(this);

    ui->clockContainer->setParent(ui->upperStack);
    setAttribute(Qt::WA_DeleteOnClose);

    foreach (QPushButton *button, findChildren<QPushButton *>())
        connect(button, &QPushButton::pressed, SoundPlayer::playClick);
}

AdjustmentWindow::~AdjustmentWindow()
{
    delete ui;
}

void AdjustmentWindow::on_btnAdjust_clicked()
{
    YesNoPopupDlg* w = new YesNoPopupDlg(this,tr("모든 설정 값을 공장(출고)초기화\n값으로 변경 하시겠습니까?"));
    //w->raise();
    int dlgrst = w->exec();
    dlgrst = w->result();
    if(dlgrst == QDialog::Accepted) {
        //Process Init Value;
        qDebug() << "Accepted";
    }
    else qDebug() <<"Rejected";
}

void AdjustmentWindow::on_backButton_clicked()
{
    close();
}


void AdjustmentWindow::keyPressEvent(QKeyEvent *event){
    switch (event->key())
    {
    case 0x01000030:    // Turn left
        focusPreviousChild();
        break;
    case 0x01000032:    // Turn right
        focusNextChild();
        break;
    }
}

void AdjustmentWindow::keyReleaseEvent(QKeyEvent *event){
    switch (event->key())
    {
    case 0x01000030:    // Turn left
        focusPreviousChild();
        break;
    case 0x01000031:    // Push
    {
        QPushButton *btn = qobject_cast<QPushButton*>(focusWidget());
        if(btn != NULL){
            btn->click();
        }
        break;
    }
    case 0x01000032:    // Turn right
        focusNextChild();
        break;
    }
}