servicehistorymain.cpp 2.31 KB
#include <QKeyEvent>
#include <QDebug>
#include "servicehistorymain.h"
#include "ui_servicehistorymain.h"
#include "historylistwindow.h"
#include "soundplayer.h"

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

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

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

    connect(ui->backButton, SIGNAL(released()), this, SLOT(close()));
}

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

void ServiceHistoryMain::on_btnUpperBunner_clicked()
{
    HistoryListWindow *w = new HistoryListWindow(this);
    w->setWindosDataSet(ERROR_HISTORY_UPPERBUNNER);
    w->setWindowModality(Qt::WindowModal);
    w->showFullScreen();
}

void ServiceHistoryMain::on_btnSteamBunner_clicked()
{
    HistoryListWindow *w = new HistoryListWindow(this);
    w->setWindosDataSet(ERROR_HISTORY_STEAMBUNNER);
    w->setWindowModality(Qt::WindowModal);
    w->showFullScreen();
}

void ServiceHistoryMain::on_btnLowerBunner_clicked()
{
    HistoryListWindow *w = new HistoryListWindow(this);
    w->setWindosDataSet(ERROR_HISTORY_LOWERBUNNER);
    w->setWindowModality(Qt::WindowModal);
    w->showFullScreen();
}

void ServiceHistoryMain::on_btnErrorTotal_clicked()
{
    HistoryListWindow *w = new HistoryListWindow(this);
    w->setWindosDataSet(ERROR_HISTORY_TOTAL);
    w->setWindowModality(Qt::WindowModal);
    w->showFullScreen();
}

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

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