From cb73caa1ec9092fb10a4be8e4511e76e2251a5b2 Mon Sep 17 00:00:00 2001 From: Yoann Laissus Date: Tue, 8 Feb 2011 17:17:07 +0100 Subject: Hide bars on ESC key pressed: zoombar first, findbar second. Reviewed by adjam BUG:264929 --- src/mainwindow.cpp | 39 +++++++++++++++++++++++++++++++-------- src/mainwindow.h | 2 +- 2 files changed, 32 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 3d76d35f..62f420b7 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -1089,14 +1089,6 @@ void MainWindow::openNext(Qt::MouseButtons mouseButtons, Qt::KeyboardModifiers k void MainWindow::keyPressEvent(QKeyEvent *event) { - // hide findbar - if (event->key() == Qt::Key_Escape) - { - m_findBar->hide(); - currentTab()->setFocus(); // give focus to web pages - return; - } - // ctrl + tab action if ((event->modifiers() == Qt::ControlModifier) && (event->key() == Qt::Key_Tab)) { @@ -1115,6 +1107,37 @@ void MainWindow::keyPressEvent(QKeyEvent *event) } +bool MainWindow::event(QEvent *event) +{ + // Avoid a conflict with window-global actions + if (event->type() == QEvent::ShortcutOverride || event->type() == QEvent::KeyPress) + { + QKeyEvent *kev = static_cast(event); + if (kev->key() == Qt::Key_Escape) + { + // if zoombar is visible, hide it + if (m_zoomBar->isVisible()) + { + m_zoomBar->hide(); + event->accept(); + currentTab()->setFocus(); + return true; + } + + // if findbar is visible, hide it + if (m_findBar->isVisible()) + { + m_findBar->hide(); + event->accept(); + currentTab()->setFocus(); + return true; + } + } + } + return KMainWindow::event(event); +} + + void MainWindow::notifyMessage(const QString &msg, Rekonq::Notify status) { if (this != QApplication::activeWindow()) diff --git a/src/mainwindow.h b/src/mainwindow.h index 565843f2..00bd40a5 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -129,7 +129,7 @@ protected: * Filters out ESC key to show/hide the search bar */ void keyPressEvent(QKeyEvent *event); - + bool event(QEvent *event); bool queryClose(); private Q_SLOTS: -- cgit v1.2.1