From 983f2f1af4afeaa0539ffe533626233becf28a75 Mon Sep 17 00:00:00 2001 From: Yoann Laissus Date: Fri, 19 Feb 2010 15:10:40 +0100 Subject: Workaround the bug of qtwebkit in the function findText(). An empty string doesn't clear the selection. --- src/findbar.cpp | 6 ++++++ src/mainwindow.cpp | 32 ++++++++++++++++++++++++++++---- 2 files changed, 34 insertions(+), 4 deletions(-) (limited to 'src') 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); } -- cgit v1.2.1 From e88fc26105ce8ba41ac988ff428596baefd443d7 Mon Sep 17 00:00:00 2001 From: Yoann Laissus Date: Fri, 19 Feb 2010 15:27:58 +0100 Subject: The text is now instantly checked when the checkbox match case is toggled Fix the selected text when the findBar is closed and open --- src/findbar.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/findbar.cpp b/src/findbar.cpp index d8ae08cc..2b464978 100644 --- a/src/findbar.cpp +++ b/src/findbar.cpp @@ -64,7 +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())); + connect(hideButton, SIGNAL(clicked()), mainwindow, SLOT(findNext())); layout->addWidget(hideButton); layout->setAlignment(hideButton, Qt::AlignLeft | Qt::AlignTop); @@ -92,6 +92,7 @@ FindBar::FindBar(KMainWindow *mainwindow) // Case sensitivity. Deliberately set so this is off by default. m_matchCase->setCheckState(Qt::Unchecked); m_matchCase->setTristate(false); + connect(m_matchCase, SIGNAL(toggled(bool)), mainwindow, SLOT(findNext())); layout->addWidget(m_matchCase); // stretching widget on the left @@ -143,7 +144,7 @@ void FindBar::show() // emit a new find signal with the current text QString temp = m_lineEdit->text(); m_lineEdit->setText(""); - m_lineEdit->setText(m_lineEdit->text()); + m_lineEdit->setText(temp); } -- cgit v1.2.1 From cbf12dbaa27add9bfdfda728d7c952429262ca99 Mon Sep 17 00:00:00 2001 From: Yoann Laissus Date: Fri, 19 Feb 2010 15:42:22 +0100 Subject: Fix a small regression : the color of the lineEdit of the findBar is not correctly updated when it's empty --- src/mainwindow.cpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index f9f211ca..22cf8c6c 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -774,11 +774,6 @@ void MainWindow::find(const QString & search) return; m_lastSearch = search; - if(m_lastSearch.isEmpty()) - { - currentTab()->view()->page()->focusNextPrevChild(true); - return; - } findNext(); } @@ -788,7 +783,7 @@ void MainWindow::findNext() if (!currentTab()) return; - if(m_lastSearch.isEmpty() || m_findBar->isHidden()) + if(m_findBar->isHidden()) { currentTab()->view()->page()->focusNextPrevChild(true); return; @@ -810,7 +805,7 @@ void MainWindow::findPrevious() if (!currentTab()) return; - if(m_lastSearch.isEmpty() || m_findBar->isHidden()) + if(m_findBar->isHidden()) { currentTab()->view()->page()->focusNextPrevChild(true); return; -- cgit v1.2.1 From 8f9db7ef7ce4116c3ea7a34a49d5db04602b4c06 Mon Sep 17 00:00:00 2001 From: Yoann Laissus Date: Fri, 19 Feb 2010 22:27:05 +0100 Subject: Get rid of the selection of the next found expression when the checkbox matchCase is toggled --- src/findbar.cpp | 2 +- src/mainwindow.cpp | 17 ++++++++++++++++- src/mainwindow.h | 1 + 3 files changed, 18 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/findbar.cpp b/src/findbar.cpp index 2b464978..6b92f130 100644 --- a/src/findbar.cpp +++ b/src/findbar.cpp @@ -92,7 +92,7 @@ FindBar::FindBar(KMainWindow *mainwindow) // Case sensitivity. Deliberately set so this is off by default. m_matchCase->setCheckState(Qt::Unchecked); m_matchCase->setTristate(false); - connect(m_matchCase, SIGNAL(toggled(bool)), mainwindow, SLOT(findNext())); + connect(m_matchCase, SIGNAL(toggled(bool)), mainwindow, SLOT(matchCaseUpdate())); layout->addWidget(m_matchCase); // stretching widget on the left diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 22cf8c6c..d61b56f9 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -777,7 +777,22 @@ void MainWindow::find(const QString & search) findNext(); } - +void MainWindow::matchCaseUpdate() +{ + if (!currentTab()) + return; + + QWebPage::FindFlags options = QWebPage::FindWrapsAroundDocument; + + if (m_findBar->matchCase()) + options |= QWebPage::FindCaseSensitively; + + currentTab()->view()->findText(m_lastSearch, QWebPage::FindBackward | QWebPage::FindWrapsAroundDocument); + bool found = currentTab()->view()->findText(m_lastSearch, options); + m_findBar->notifyMatch(found); + if(!found) + currentTab()->view()->page()->focusNextPrevChild(true); +} void MainWindow::findNext() { if (!currentTab()) diff --git a/src/mainwindow.h b/src/mainwindow.h index c104ad4d..db75b1bd 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -127,6 +127,7 @@ private slots: // Find Action slots void find(const QString &); + void matchCaseUpdate(); void findNext(); void findPrevious(); -- cgit v1.2.1