#include <QImage>
#include <QKeyEvent>
#include <QLabel>
#include <QObject>
#include <QPixmap>
#include <QTimer>
#include <QWidget>
#include <iostream>

class MainWindow : public QWidget {
  public:
    std::function<void(QKeyEvent *)> keyDownCallBack;

    MainWindow() : display(QLabel(this)) {
        setAutoFillBackground(true);
        setGeometry(0, 0, 500, 500);
        display.setFocusPolicy(Qt::StrongFocus);
    }

    void updateLabel(uint8_t *pixel) {
        QImage img((unsigned char *)pixel, 64, 64, QImage::Format_RGB888);
        display.setPixmap(QPixmap::fromImage(img).scaled(size() * 1));
    }

    void keyPressEvent(QKeyEvent *e) {
        keyDownCallBack(e);
        QWidget::keyPressEvent(e);
    }

  private:
    QLabel display;
};
