From 139c3bca0373aa89384059070812a85821ea1a19 Mon Sep 17 00:00:00 2001 From: megabigbug Date: Sat, 25 Jul 2009 19:01:56 +0200 Subject: Remove notification for search text Notify matching by changing the background color of the text field --- src/findbar.cpp | 24 ++++++++++++++++++++++++ src/findbar.h | 2 ++ src/mainwindow.cpp | 10 ++-------- 3 files changed, 28 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/findbar.cpp b/src/findbar.cpp index 3efe470b..b2dc5344 100644 --- a/src/findbar.cpp +++ b/src/findbar.cpp @@ -29,12 +29,14 @@ #include #include #include +#include // Qt Includes #include #include #include #include +#include #include #include @@ -139,6 +141,28 @@ void FindBar::keyPressEvent(QKeyEvent* event) emit searchString(m_lineEdit->text()); return; } + QWidget::keyPressEvent(event); } +void FindBar::notifyMatch(bool match) +{ + QPalette p = m_lineEdit->palette(); + + if (m_lineEdit->text().isEmpty()) + { + p.setColor(QPalette::Base, QColor(KApplication::palette().color(QPalette::Active, QPalette::Base))); + } + else if (match) + { + p.setColor(QPalette::Base, QColor(186, 249, 206)); + } + else + { + p.setColor(QPalette::Base, QColor(247, 230, 230)); + } + + m_lineEdit->setPalette(p); +} + + diff --git a/src/findbar.h b/src/findbar.h index 6a6137ab..f297e6d2 100644 --- a/src/findbar.h +++ b/src/findbar.h @@ -51,6 +51,7 @@ public: public slots: void clear(); void show(); + void notifyMatch(bool match); protected Q_SLOTS: void keyPressEvent(QKeyEvent* event); @@ -61,6 +62,7 @@ signals: private: KLineEdit *m_lineEdit; QCheckBox *m_matchCase; + }; #endif diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index b2e5106c..27b9a65b 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -614,10 +614,7 @@ void MainWindow::slotFindNext() if (m_findBar->matchCase()) options |= QWebPage::FindCaseSensitively; - if (!currentTab()->findText(m_lastSearch, options)) - { - notifyMessage(QString(m_lastSearch) + i18n(" not found.")); - } + m_findBar->notifyMatch(currentTab()->findText(m_lastSearch, options)); } @@ -630,10 +627,7 @@ void MainWindow::slotFindPrevious() if (m_findBar->matchCase()) options |= QWebPage::FindCaseSensitively; - if (!currentTab()->findText(m_lastSearch, options)) - { - notifyMessage(QString(m_lastSearch) + i18n(" not found.")); - } + m_findBar->notifyMatch(currentTab()->findText(m_lastSearch, options)); } -- cgit v1.2.1 From fce9e7c708eacbd91b81bc7bdfa7789e69317bea Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sat, 25 Jul 2009 20:13:35 +0200 Subject: Fixing codestyle and changing a bit red color --- src/findbar.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/findbar.cpp b/src/findbar.cpp index b2dc5344..0656eef5 100644 --- a/src/findbar.cpp +++ b/src/findbar.cpp @@ -151,17 +151,19 @@ void FindBar::notifyMatch(bool match) if (m_lineEdit->text().isEmpty()) { - p.setColor(QPalette::Base, QColor(KApplication::palette().color(QPalette::Active, QPalette::Base))); + p.setColor(QPalette::Base, QColor(KApplication::palette().color(QPalette::Active, QPalette::Base))); } - else if (match) + else { - p.setColor(QPalette::Base, QColor(186, 249, 206)); + if (match) + { + p.setColor(QPalette::Base, QColor(186, 249, 206)); + } + else + { + p.setColor(QPalette::Base, QColor(247, 130, 130)); // previous were 247, 230, 230 + } } - else - { - p.setColor(QPalette::Base, QColor(247, 230, 230)); - } - m_lineEdit->setPalette(p); } -- cgit v1.2.1