From 2c11a95da6772a63d85905d4712a1a2d016a9e1e Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sat, 6 Feb 2010 01:49:54 +0100 Subject: FIx focus on browsing (FIRST STEP) and on findbar hiding --- src/application.cpp | 2 +- src/findbar.cpp | 15 +++++++++------ src/findbar.h | 2 +- src/mainview.cpp | 6 +++--- src/mainwindow.cpp | 1 + src/webtab.cpp | 3 +++ 6 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/application.cpp b/src/application.cpp index cfd4d060..14fd5ce0 100644 --- a/src/application.cpp +++ b/src/application.cpp @@ -382,8 +382,8 @@ void Application::loadResolvedUrl(ThreadWeaver::Job *job) if (view) { - view->setFocus(); view->load(url); + view->setFocus(); // we are sure of the url now, let's add it to history // anyway we store here just http sites because local and ftp ones are diff --git a/src/findbar.cpp b/src/findbar.cpp index bd1a5137..9efb9c6a 100644 --- a/src/findbar.cpp +++ b/src/findbar.cpp @@ -143,12 +143,6 @@ void FindBar::show() void FindBar::keyPressEvent(QKeyEvent* event) { - if (event->key() == Qt::Key_Escape) - { - hide(); - m_hideTimer->stop(); - return; - } if (event->key() == Qt::Key_Return && !m_lineEdit->text().isEmpty()) { emit searchString(m_lineEdit->text()); @@ -158,6 +152,7 @@ void FindBar::keyPressEvent(QKeyEvent* event) QWidget::keyPressEvent(event); } + void FindBar::notifyMatch(bool match) { QPalette p = m_lineEdit->palette(); @@ -180,3 +175,11 @@ void FindBar::notifyMatch(bool match) m_lineEdit->setPalette(p); m_hideTimer->start(60000); } + + + +void FindBar::hide() +{ + m_hideTimer->stop(); + QWidget::hide(); +} diff --git a/src/findbar.h b/src/findbar.h index fa369f66..5a41c0bc 100644 --- a/src/findbar.h +++ b/src/findbar.h @@ -56,6 +56,7 @@ public: public slots: void clear(); void show(); + void hide(); void notifyMatch(bool match); protected Q_SLOTS: @@ -68,7 +69,6 @@ private: KLineEdit *m_lineEdit; QCheckBox *m_matchCase; QTimer *m_hideTimer; - }; #endif diff --git a/src/mainview.cpp b/src/mainview.cpp index b26e7466..bc9d0bda 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -308,7 +308,7 @@ void MainView::currentChanged(int index) emit browserTabLoading(false); // set focus to the current webview - tab->setFocus(); + tab->view()->setFocus(); } @@ -507,8 +507,8 @@ void MainView::closeTab(int index) } removeTab(index); - updateTabBar(); // UI operation: do it ASAP!! - tab->deleteLater(); // webView is scheduled for deletion. + updateTabBar(); // UI operation: do it ASAP!! + tab->deleteLater(); // webView is scheduled for deletion. emit tabsChanged(); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index ffc9f508..9df24692 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -925,6 +925,7 @@ void MainWindow::keyPressEvent(QKeyEvent *event) if (event->key() == Qt::Key_Escape) { m_findBar->hide(); + currentTab()->setFocus(); // give focus to web pages return; } diff --git a/src/webtab.cpp b/src/webtab.cpp index b1f2cdfc..b3eb71f0 100644 --- a/src/webtab.cpp +++ b/src/webtab.cpp @@ -64,6 +64,9 @@ WebTab::WebTab(QWidget* parent) , m_view( new WebView(this) ) , m_progress(0) { + // fix focus handling + setFocusProxy( m_view ); + QVBoxLayout* l = new QVBoxLayout(this); l->setMargin(0); l->setSpacing(0); -- cgit v1.2.1