summaryrefslogtreecommitdiff
path: root/src/findbar.cpp
diff options
context:
space:
mode:
authorBenjamin Poulain <benjamin.poulain@nokia.com>2010-08-22 01:17:43 +0200
committerBenjamin Poulain <benjamin.poulain@nokia.com>2010-08-22 04:10:58 +0200
commitfe02d0962810b1ebca33c219274a5e3390de5286 (patch)
treec922c970b2cc3039b41775abe1089e452f9ad515 /src/findbar.cpp
parentRestore bk icon on the right (diff)
downloadrekonq-fe02d0962810b1ebca33c219274a5e3390de5286.tar.xz
Make the FindBar a bit more robust
The FindBar was slots show() and hide() instead of the virtual method QWidget::setVisible(). This can lead to subtle bugs, because the behavior is different depending on the type of call (signal-slot connection VS direct call on a pointer to QWidget) and the function called (hide() is != than setVisible(false)).
Diffstat (limited to 'src/findbar.cpp')
-rw-r--r--src/findbar.cpp38
1 files changed, 15 insertions, 23 deletions
diff --git a/src/findbar.cpp b/src/findbar.cpp
index b3b80fac..18a4f168 100644
--- a/src/findbar.cpp
+++ b/src/findbar.cpp
@@ -138,25 +138,27 @@ bool FindBar::highlightAllState() const
return m_highlightAll->isChecked();
}
-
-void FindBar::show()
+void FindBar::setVisible(bool visible)
{
- // show findbar if not visible
- if (isHidden())
- {
- emit visibilityChanged(true);
- QWidget::show();
+ QWidget::setVisible(visible);
+
+ if (visible != isVisible())
+ emit visibilityChanged(visible);
+
+ if (visible) {
+ // show findbar if not visible
emit searchString(m_lineEdit->text());
- }
- m_hideTimer->start(60000);
+ m_hideTimer->start(60000);
- // set focus to findbar if user select showFindBar shortcut
- m_lineEdit->setFocus();
- m_lineEdit->selectAll();
+ // set focus to findbar if user select showFindBar shortcut
+ m_lineEdit->setFocus();
+ m_lineEdit->selectAll();
+ } else {
+ m_hideTimer->stop();
+ }
}
-
void FindBar::notifyMatch(bool match)
{
QPalette p = m_lineEdit->palette();
@@ -180,16 +182,6 @@ void FindBar::notifyMatch(bool match)
m_hideTimer->start(60000);
}
-
-void FindBar::hide()
-{
- m_hideTimer->stop();
- emit visibilityChanged(false);
- QWidget::hide();
- emit(searchString(m_lineEdit->text()));
-}
-
-
void FindBar::toggleVisibility()
{
isVisible() ? hide() : show();