Commit 9f5c0502 authored by Michael Augaitis's avatar Michael Augaitis Committed by Albert Astals Cid
Browse files

Make ESC key leave fullscreen

BUG: 366276, 417337, 269677
parent 53a9f566
Pipeline #50363 passed with stage
in 10 minutes and 26 seconds
...@@ -295,7 +295,7 @@ bool AnnotWindow::eventFilter(QObject *o, QEvent *e) ...@@ -295,7 +295,7 @@ bool AnnotWindow::eventFilter(QObject *o, QEvent *e)
if (e->type() == QEvent::ShortcutOverride) { if (e->type() == QEvent::ShortcutOverride) {
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(e); QKeyEvent *keyEvent = static_cast<QKeyEvent *>(e);
if (keyEvent->key() == Qt::Key_Escape) { if (keyEvent->key() == Qt::Key_Escape) {
close(); e->accept();
return true; return true;
} }
} else if (e->type() == QEvent::KeyPress) { } else if (e->type() == QEvent::KeyPress) {
...@@ -306,6 +306,9 @@ bool AnnotWindow::eventFilter(QObject *o, QEvent *e) ...@@ -306,6 +306,9 @@ bool AnnotWindow::eventFilter(QObject *o, QEvent *e)
} else if (keyEvent == QKeySequence::Redo) { } else if (keyEvent == QKeySequence::Redo) {
m_document->redo(); m_document->redo();
return true; return true;
} else if (keyEvent->key() == Qt::Key_Escape) {
close();
return true;
} }
} else if (e->type() == QEvent::FocusIn) { } else if (e->type() == QEvent::FocusIn) {
raise(); raise();
......
...@@ -1972,7 +1972,12 @@ void PageView::resizeEvent(QResizeEvent *e) ...@@ -1972,7 +1972,12 @@ void PageView::resizeEvent(QResizeEvent *e)
void PageView::keyPressEvent(QKeyEvent *e) void PageView::keyPressEvent(QKeyEvent *e)
{ {
e->accept(); // Ignore ESC key press to send to shell.cpp
if (e->key() != Qt::Key_Escape) {
e->accept();
} else {
e->ignore();
}
// if performing a selection or dyn zooming, disable keys handling // if performing a selection or dyn zooming, disable keys handling
if ((d->mouseSelecting && e->key() != Qt::Key_Escape) || (QApplication::mouseButtons() & Qt::MiddleButton)) if ((d->mouseSelecting && e->key() != Qt::Key_Escape) || (QApplication::mouseButtons() & Qt::MiddleButton))
......
...@@ -160,6 +160,13 @@ void Shell::reloadAllXML() ...@@ -160,6 +160,13 @@ void Shell::reloadAllXML()
} }
} }
void Shell::keyPressEvent(QKeyEvent *e)
{
if (e->key() == Qt::Key_Escape && window()->isFullScreen()) {
setFullScreen(false);
}
}
bool Shell::eventFilter(QObject *obj, QEvent *event) bool Shell::eventFilter(QObject *obj, QEvent *event)
{ {
QDragMoveEvent *dmEvent = dynamic_cast<QDragMoveEvent *>(event); QDragMoveEvent *dmEvent = dynamic_cast<QDragMoveEvent *>(event);
......
...@@ -114,6 +114,7 @@ protected: ...@@ -114,6 +114,7 @@ protected:
bool queryClose() override; bool queryClose() override;
void showEvent(QShowEvent *event) override; void showEvent(QShowEvent *event) override;
void keyPressEvent(QKeyEvent *) override;
private Q_SLOTS: private Q_SLOTS:
void fileOpen(); void fileOpen();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment