diff --git a/OSBindings/Qt/mainwindow.cpp b/OSBindings/Qt/mainwindow.cpp index 564baba2e..cad97c28c 100644 --- a/OSBindings/Qt/mainwindow.cpp +++ b/OSBindings/Qt/mainwindow.cpp @@ -1,7 +1,9 @@ -#include #include #include +#include +#include + #include "mainwindow.h" #include "settings.h" #include "timer.h" @@ -217,7 +219,9 @@ void MainWindow::tile(const QMainWindow *previous) { topFrameWidth = 40; const QPoint pos = previous->pos() + 2 * QPoint(topFrameWidth, topFrameWidth); +#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) if (screen()->availableGeometry().contains(rect().bottomRight() + pos)) +#endif move(pos); } @@ -687,25 +691,6 @@ void MainWindow::dropEvent(QDropEvent* event) { } } -// MARK: Input capture. - -bool MainWindow::eventFilter(QObject *obj, QEvent *event) { - switch(event->type()) { - case QEvent::KeyPress: - case QEvent::KeyRelease: { - const auto keyEvent = static_cast(event); - if(!processEvent(keyEvent)) { - return false; - } - } break; - - default: - break; - } - - return QObject::eventFilter(obj, event); -} - void MainWindow::setUIPhase(UIPhase phase) { uiPhase = phase; @@ -750,6 +735,14 @@ void MainWindow::setUIPhase(UIPhase phase) { // MARK: - Event Processing +void MainWindow::keyPressEvent(QKeyEvent *event) { + processEvent(event); +} + +void MainWindow::keyReleaseEvent(QKeyEvent *event) { + processEvent(event); +} + bool MainWindow::processEvent(QKeyEvent *event) { if(!machine) return true; diff --git a/OSBindings/Qt/mainwindow.h b/OSBindings/Qt/mainwindow.h index ecd7571b9..98ee64c99 100644 --- a/OSBindings/Qt/mainwindow.h +++ b/OSBindings/Qt/mainwindow.h @@ -32,7 +32,8 @@ class MainWindow : public QMainWindow, public Outputs::Speaker::Speaker::Delegat explicit MainWindow(const QString &fileName); protected: - bool eventFilter(QObject *obj, QEvent *event) override; + void keyPressEvent(QKeyEvent *event) override; + void keyReleaseEvent(QKeyEvent *event) override; private: std::unique_ptr ui;