[Konversation-devel] [Bug 257298] Search box open by Ctrl-F can't be dismissed with Esc
Eike Hein
hein at kde.org
Sat Nov 20 04:01:06 CET 2010
https://bugs.kde.org/show_bug.cgi?id=257298
Eike Hein <hein at kde.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
--- Comment #2 from Eike Hein <hein kde org> 2010-11-20 04:01:04 ---
commit 74f88466f964b3bb739fabf1a5a7d2eaa028ab76
branch master
Author: Eike Hein <hein at kde.org>
Date: Sat Nov 20 04:01:14 2010 +0100
Fix shortcut ambiguity when the search bar is open.
BUG:257298
diff --git a/src/viewer/searchbar.cpp b/src/viewer/searchbar.cpp
index be14384..a5679a9 100644
--- a/src/viewer/searchbar.cpp
+++ b/src/viewer/searchbar.cpp
@@ -28,6 +28,12 @@ SearchBar::SearchBar(QWidget* parent)
{
setupUi(this);
+ m_searchEdit->installEventFilter(this);
+ m_closeButton->installEventFilter(this);
+ m_findNextButton->installEventFilter(this);
+ m_findPreviousButton->installEventFilter(this);
+ m_optionsButton->installEventFilter(this);
+
m_searchFoward = false;
m_matchCase = false;
m_wholeWords = false;
@@ -44,7 +50,8 @@ SearchBar::SearchBar(QWidget* parent)
m_timer = new QTimer(this);
m_timer->setSingleShot(true);
- new QShortcut(QKeySequence(Qt::Key_Escape), this, SLOT(hide()));
+ m_closeShortcut = new QShortcut(QKeySequence(Qt::Key_Escape), this,
SLOT(hide()));
+ m_closeShortcut->setEnabled(false);
connect(m_timer, SIGNAL(timeout()), SLOT(slotFind()));
connect(m_searchEdit, SIGNAL(textChanged(const QString&)),
SLOT(slotTextChanged()));
@@ -76,6 +83,24 @@ SearchBar::~SearchBar()
{
}
+bool SearchBar::eventFilter(QObject* object, QEvent* e)
+{
+ Q_UNUSED(object);
+
+ if (e->type() == QEvent::FocusIn)
+ {
+
static_cast<Application*>(kapp)->getMainWindow()->actionCollection()->action("focus_input_box")->setEnabled(false);
+ m_closeShortcut->setEnabled(true);
+ }
+ else if (e->type() == QEvent::FocusOut)
+ {
+
static_cast<Application*>(kapp)->getMainWindow()->actionCollection()->action("focus_input_box")->setEnabled(true);
+ m_closeShortcut->setEnabled(false);
+ }
+
+ return false;
+}
+
void SearchBar::showEvent(QShowEvent *e)
{
QWidget::showEvent(e);
diff --git a/src/viewer/searchbar.h b/src/viewer/searchbar.h
index 0a71774..d52a363 100644
--- a/src/viewer/searchbar.h
+++ b/src/viewer/searchbar.h
@@ -22,6 +22,8 @@
the konvi gods
*/
+class QShortcut;
+
class KMenu;
class KIcon;
@@ -42,6 +44,8 @@ class SearchBar : public QWidget, private Ui::SearchBarBase
bool wholeWords() const;
bool fromCursor() const;
+ bool eventFilter(QObject* object, QEvent* e);
+
protected:
virtual void showEvent(QShowEvent* e);
virtual void hideEvent(QHideEvent* e);
@@ -78,6 +82,8 @@ class SearchBar : public QWidget, private Ui::SearchBarBase
bool m_matchCase;
bool m_wholeWords;
bool m_fromCursor;
+
+ QShortcut* m_closeShortcut;
};
#endif /* SEARCHBAR_H */
--
Configure bugmail: https://bugs.kde.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
More information about the Konversation-devel
mailing list