diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/findbar.cpp | 6 | ||||
-rw-r--r-- | src/mainwindow.cpp | 32 |
2 files changed, 34 insertions, 4 deletions
diff --git a/src/findbar.cpp b/src/findbar.cpp index 1cb16e3f..d8ae08cc 100644 --- a/src/findbar.cpp +++ b/src/findbar.cpp @@ -64,6 +64,7 @@ FindBar::FindBar(KMainWindow *mainwindow) hideButton->setAutoRaise(true); hideButton->setIcon(KIcon("dialog-close")); connect(hideButton, SIGNAL(clicked()), this, SLOT(hide())); + connect(hideButton, SIGNAL(clicked()), this, SLOT(findNext())); layout->addWidget(hideButton); layout->setAlignment(hideButton, Qt::AlignLeft | Qt::AlignTop); @@ -138,6 +139,11 @@ void FindBar::show() QWidget::show(); m_hideTimer->start(60000); + + // emit a new find signal with the current text + QString temp = m_lineEdit->text(); + m_lineEdit->setText(""); + m_lineEdit->setText(m_lineEdit->text()); } diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index e3beb60a..f9f211ca 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -773,33 +773,57 @@ void MainWindow::find(const QString & search) if (!currentTab()) return; m_lastSearch = search; + + if(m_lastSearch.isEmpty()) + { + currentTab()->view()->page()->focusNextPrevChild(true); + return; + } findNext(); } void MainWindow::findNext() { - if (!currentTab() && m_lastSearch.isEmpty()) + if (!currentTab()) return; + if(m_lastSearch.isEmpty() || m_findBar->isHidden()) + { + currentTab()->view()->page()->focusNextPrevChild(true); + return; + } + QWebPage::FindFlags options = QWebPage::FindWrapsAroundDocument; if (m_findBar->matchCase()) options |= QWebPage::FindCaseSensitively; - m_findBar->notifyMatch(currentTab()->view()->findText(m_lastSearch, options)); + bool found = currentTab()->view()->findText(m_lastSearch, options); + m_findBar->notifyMatch(found); + if(!found) + currentTab()->view()->page()->focusNextPrevChild(true); } void MainWindow::findPrevious() { - if (!currentTab() && m_lastSearch.isEmpty()) + if (!currentTab()) return; + if(m_lastSearch.isEmpty() || m_findBar->isHidden()) + { + currentTab()->view()->page()->focusNextPrevChild(true); + return; + } + QWebPage::FindFlags options = QWebPage::FindBackward | QWebPage::FindWrapsAroundDocument; if (m_findBar->matchCase()) options |= QWebPage::FindCaseSensitively; - m_findBar->notifyMatch(currentTab()->view()->findText(m_lastSearch, options)); + bool found = currentTab()->view()->findText(m_lastSearch, options); + m_findBar->notifyMatch(found); + if(!found) + currentTab()->view()->page()->focusNextPrevChild(true); } |