summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorJocelyn Turcotte <jocelyn.turcotte@digia.com>2014-02-10 18:04:33 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-02-13 14:28:04 +0100
commit324706a5fe9fbfd5aeaef54387dd4b08159a92a0 (patch)
tree5a99ceb64b794890fd339d0e67ea6fee5ed79abf /examples
parent9cf0007b6ff49305550754babaeb67eb85c8d5ef (diff)
Implement QWebEnginePage::findText
A few changes to the API: - Return the success result asynchronously. - FindWrapsAroundDocument and HighlightAllOccurrences are enabled by defaults and cannot be disabled. - Found text isn't updating the selection on the page like QtWebKit did, but triggers a separate state not available. A find count and current index could be exposed, but isn't in this case to keep the API delta lower. This also adds the possibility to pass bool results through the CallbackDirectory and add a new tst_QWebEnginePage::findTextResult test since the old test relied on the selection to be updated when the searched text is found. Change-Id: I8189b5aea8d832df183c6c1ae03e3f08198a9c45 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'examples')
-rw-r--r--examples/widgets/browser/browsermainwindow.cpp17
-rw-r--r--examples/widgets/browser/browsermainwindow.h1
2 files changed, 8 insertions, 10 deletions
diff --git a/examples/widgets/browser/browsermainwindow.cpp b/examples/widgets/browser/browsermainwindow.cpp
index 319e2d4c2..3cee14e9e 100644
--- a/examples/widgets/browser/browsermainwindow.cpp
+++ b/examples/widgets/browser/browsermainwindow.cpp
@@ -325,7 +325,6 @@ void BrowserMainWindow::setupMenu()
m_tabWidget->addWebAction(m_paste, QWebEnginePage::Paste);
editMenu->addSeparator();
-#if defined(QWEBENGINEPAGE_FINDTEXT)
QAction *m_find = editMenu->addAction(tr("&Find"));
m_find->setShortcuts(QKeySequence::Find);
connect(m_find, SIGNAL(triggered()), this, SLOT(slotEditFind()));
@@ -339,7 +338,6 @@ void BrowserMainWindow::setupMenu()
m_findPrevious->setShortcuts(QKeySequence::FindPrevious);
connect(m_findPrevious, SIGNAL(triggered()), this, SLOT(slotEditFindPrevious()));
editMenu->addSeparator();
-#endif
editMenu->addAction(tr("&Preferences"), this, SLOT(slotPreferences()), tr("Ctrl+,"));
@@ -557,6 +555,12 @@ void BrowserMainWindow::updateStatusbarActionText(bool visible)
m_viewStatusbar->setText(!visible ? tr("Show Status Bar") : tr("Hide Status Bar"));
}
+void BrowserMainWindow::handleFindTextResult(bool found)
+{
+ if (!found)
+ slotUpdateStatusbar(tr("\"%1\" not found.").arg(m_lastSearch));
+}
+
void BrowserMainWindow::updateToolbarActionText(bool visible)
{
m_viewToolbar->setText(!visible ? tr("Show Toolbar") : tr("Hide Toolbar"));
@@ -746,7 +750,6 @@ void BrowserMainWindow::closeEvent(QCloseEvent *event)
void BrowserMainWindow::slotEditFind()
{
-#if defined(QWEBENGINEPAGE_FINDTEXT)
if (!currentTab())
return;
bool ok;
@@ -755,28 +758,22 @@ void BrowserMainWindow::slotEditFind()
m_lastSearch, &ok);
if (ok && !search.isEmpty()) {
m_lastSearch = search;
- if (!currentTab()->findText(m_lastSearch))
- slotUpdateStatusbar(tr("\"%1\" not found.").arg(m_lastSearch));
+ currentTab()->findText(m_lastSearch, 0, invoke(this, &BrowserMainWindow::handleFindTextResult));
}
-#endif
}
void BrowserMainWindow::slotEditFindNext()
{
-#if defined(QWEBENGINEPAGE_FINDTEXT)
if (!currentTab() && !m_lastSearch.isEmpty())
return;
currentTab()->findText(m_lastSearch);
-#endif
}
void BrowserMainWindow::slotEditFindPrevious()
{
-#if defined(QWEBENGINEPAGE_FINDTEXT)
if (!currentTab() && !m_lastSearch.isEmpty())
return;
currentTab()->findText(m_lastSearch, QWebEnginePage::FindBackward);
-#endif
}
void BrowserMainWindow::slotViewZoomIn()
diff --git a/examples/widgets/browser/browsermainwindow.h b/examples/widgets/browser/browsermainwindow.h
index 2ad5ab62e..3c3df9117 100644
--- a/examples/widgets/browser/browsermainwindow.h
+++ b/examples/widgets/browser/browsermainwindow.h
@@ -137,6 +137,7 @@ private:
void setupMenu();
void setupToolBar();
void updateStatusbarActionText(bool visible);
+ void handleFindTextResult(bool found);
private:
QToolBar *m_navigationBar;