Skip to content

Commit

Permalink
Fix key events in timeline window
Browse files Browse the repository at this point in the history
  • Loading branch information
rodlie committed Nov 4, 2023
1 parent e476568 commit 8642209
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/app/GUI/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1282,6 +1282,7 @@ void MainWindow::openTimelineWindow()
tr("Timeline"),
QString("TimelineWindow"),
true,
true,
true);
}
mTimelineWindow->focusWindow();
Expand Down Expand Up @@ -1994,7 +1995,7 @@ void MainWindow::closeEvent(QCloseEvent *e)

bool MainWindow::processKeyEvent(QKeyEvent *event)
{
if (isActiveWindow()) {
if (isActiveWindow() || (mTimelineWindow && mTimelineWindow->isActiveWindow())) {
bool returnBool = false;
if (event->type() == QEvent::KeyPress &&
mTimeline->processKeyPress(event))
Expand Down
9 changes: 8 additions & 1 deletion src/app/GUI/window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,18 @@
#include <QVBoxLayout>
#include <QWindow>

#include "mainwindow.h"

Window::Window(QWidget *parent,
QWidget *child,
const QString title,
const QString id,
bool visible,
bool blockEscKey)
bool blockEscKey,
bool forwardKeys)
: QDialog(parent)
, mBlockEscKey(blockEscKey)
, mForwardKeys(forwardKeys)
{
setWindowFlags(Qt::Window |
Qt::WindowTitleHint |
Expand Down Expand Up @@ -67,6 +71,9 @@ void Window::focusWindow()

void Window::keyPressEvent(QKeyEvent *event)
{
if (mForwardKeys) {
MainWindow::sGetInstance()->processKeyEvent(event);
}
if (mBlockEscKey && event->key() == Qt::Key_Escape) { return; }
QDialog::keyPressEvent(event);
}
Expand Down
4 changes: 3 additions & 1 deletion src/app/GUI/window.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ class Window : public QDialog
const QString title,
const QString id,
bool visible = true,
bool blockEscKey = true);
bool blockEscKey = true,
bool forwardKeys = false);
~Window();
void focusWindow();

Expand All @@ -48,6 +49,7 @@ class Window : public QDialog
void loadState(bool visible = true);
void saveState();
bool mBlockEscKey;
bool mForwardKeys;
};

#endif // WINDOW_H

0 comments on commit 8642209

Please sign in to comment.