diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/findbar.cpp | 26 | ||||
-rw-r--r-- | src/findbar.h | 4 | ||||
-rw-r--r-- | src/mainwindow.cpp | 20 | ||||
-rw-r--r-- | src/mainwindow.h | 1 |
4 files changed, 44 insertions, 7 deletions
diff --git a/src/findbar.cpp b/src/findbar.cpp index 4c780aca..94def263 100644 --- a/src/findbar.cpp +++ b/src/findbar.cpp @@ -52,9 +52,13 @@ FindBar::FindBar(QWidget *parent) : QWidget(parent) , m_lineEdit(new KLineEdit(this)) - , m_matchCase(new QCheckBox(i18n("&Match case"), this)) , m_hideTimer(new QTimer(this)) -{ + , m_matchCase(new QCheckBox(i18n("&Match case"), this)) + , m_highlightAll(new QCheckBox(i18n("&Highlight All"), this)) +{ + // mainwindow pointer + MainWindow *window = qobject_cast<MainWindow *>(parent); + QHBoxLayout *layout = new QHBoxLayout; // cosmetic @@ -65,6 +69,7 @@ FindBar::FindBar(QWidget *parent) hideButton->setAutoRaise(true); hideButton->setIcon(KIcon("dialog-close")); connect(hideButton, SIGNAL(clicked()), this, SLOT(hide())); + connect(hideButton, SIGNAL(clicked()), window, SLOT(highlightAll())); layout->addWidget(hideButton); layout->setAlignment(hideButton, Qt::AlignLeft | Qt::AlignTop); @@ -75,9 +80,6 @@ FindBar::FindBar(QWidget *parent) QLabel *label = new QLabel(i18n("Find:")); layout->addWidget(label); - // mainwindow pointer - MainWindow *window = qobject_cast<MainWindow *>(parent); - // lineEdit, focusProxy setFocusProxy(m_lineEdit); m_lineEdit->setMaximumWidth(250); @@ -92,13 +94,19 @@ FindBar::FindBar(QWidget *parent) connect(findPrev, SIGNAL(clicked()), window, SLOT(findPrevious())); layout->addWidget(findNext); layout->addWidget(findPrev); - + // 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)), window, SLOT(matchCaseUpdate())); layout->addWidget(m_matchCase); + // Hightlight All. On by default + m_highlightAll->setCheckState(Qt::Checked); + m_highlightAll->setTristate(false); + connect(m_highlightAll, SIGNAL(toggled(bool)), window, SLOT(highlightAll())); + layout->addWidget(m_highlightAll); + // stretching widget on the left layout->addStretch(); @@ -126,6 +134,12 @@ bool FindBar::matchCase() const } +bool FindBar::highlightAllState() const +{ + return m_highlightAll->isChecked(); +} + + void FindBar::show() { // show findbar if not visible diff --git a/src/findbar.h b/src/findbar.h index 7a4efc59..78615f9a 100644 --- a/src/findbar.h +++ b/src/findbar.h @@ -53,6 +53,7 @@ public: KLineEdit *lineEdit() const; bool matchCase() const; void notifyMatch(bool match); + bool highlightAllState() const; public slots: void show(); @@ -63,8 +64,9 @@ signals: private: KLineEdit *m_lineEdit; - QCheckBox *m_matchCase; QTimer *m_hideTimer; + QCheckBox *m_matchCase; + QCheckBox *m_highlightAll; }; #endif diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 60784af0..e90a5903 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -794,6 +794,8 @@ void MainWindow::findNext() return; } + highlightAll(); + QWebPage::FindFlags options = QWebPage::FindWrapsAroundDocument; if (m_findBar->matchCase()) options |= QWebPage::FindCaseSensitively; @@ -823,6 +825,24 @@ void MainWindow::findPrevious() m_findBar->notifyMatch(found); } +void MainWindow::highlightAll() +{ + if (!currentTab()) + return; + + QWebPage::FindFlags options = QWebPage::HighlightAllOccurrences; + + currentTab()->view()->findText("", options); //Clear an existing highlight + + if(m_findBar->highlightAllState() && !m_findBar->isHidden()) + { + if (m_findBar->matchCase()) + options |= QWebPage::FindCaseSensitively; + + currentTab()->view()->findText(m_lastSearch, options); + } +} + void MainWindow::zoomIn() { diff --git a/src/mainwindow.h b/src/mainwindow.h index 57b88dfd..e9da090d 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -130,6 +130,7 @@ private slots: void matchCaseUpdate(); void findNext(); void findPrevious(); + void highlightAll(); // Zoom slots void zoomIn(); |