Accept Ctrl+F while the inputline is focused
authorManuel Nickschas <sputnick@quassel-irc.org>
Tue, 25 Aug 2009 22:15:23 +0000 (00:15 +0200)
committerManuel Nickschas <sputnick@quassel-irc.org>
Tue, 25 Aug 2009 22:15:23 +0000 (00:15 +0200)
Fixes #772.

src/qtui/inputwidget.cpp
src/qtui/inputwidget.h

index ce9189e..11e3ec3 100644 (file)
@@ -49,6 +49,7 @@ InputWidget::InputWidget(QWidget *parent)
   ui.ownNick->setSizeAdjustPolicy(QComboBox::AdjustToContents);
   ui.ownNick->installEventFilter(new MouseWheelFilter(this));
   ui.inputEdit->installEventFilter(new JumpKeyHandler(this));
+  ui.inputEdit->installEventFilter(this);
 
   ui.inputEdit->setMinHeight(1);
   ui.inputEdit->setMaxHeight(5);
@@ -114,32 +115,31 @@ bool InputWidget::eventFilter(QObject *watched, QEvent *event) {
   if(event->type() != QEvent::KeyPress)
     return false;
 
+  QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
+
   // keys from BufferView should be sent to (and focus) the input line
   BufferView *view = qobject_cast<BufferView *>(watched);
   if(view) {
-    QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
     if(keyEvent->text().length() == 1 && !(keyEvent->modifiers() & (Qt::ControlModifier ^ Qt::AltModifier)) ) { // normal key press
       QChar c = keyEvent->text().at(0);
       if(c.isLetterOrNumber() || c.isSpace() || c.isPunct() || c.isSymbol()) {
         setFocus();
         QCoreApplication::sendEvent(inputLine(), keyEvent);
         return true;
-      } else
-        return false;
+      }
     }
-  }
-  return false;
-}
-
-void InputWidget::keyPressEvent(QKeyEvent * event) {
-  if(event->matches(QKeySequence::Find)) {
-    QAction *act = GraphicalUi::actionCollection()->action("ToggleSearchBar");
-    if(act) {
-      act->toggle();
-      return;
+    return false;
+  } else if(watched == ui.inputEdit) {
+    if(keyEvent->matches(QKeySequence::Find)) {
+      QAction *act = GraphicalUi::actionCollection()->action("ToggleSearchBar");
+      if(act) {
+        act->toggle();
+        return true;
+      }
     }
+    return false;
   }
-  AbstractItemView::keyPressEvent(event);
+  return false;
 }
 
 void InputWidget::currentChanged(const QModelIndex &current, const QModelIndex &previous) {
@@ -285,7 +285,7 @@ void InputWidget::updateNickSelector() const {
     if(!me->userModes().isEmpty())
       nicks[nickIdx] += QString(" (+%1)").arg(me->userModes());
   }
-      
+
   ui.ownNick->addItems(nicks);
 
   if(me && me->isAway())
index aeb63f8..7ba9046 100644 (file)
@@ -44,7 +44,6 @@ public:
 
 protected:
   virtual bool eventFilter(QObject *watched, QEvent *event);
-  virtual void keyPressEvent(QKeyEvent * event);
 
 protected slots:
   virtual void currentChanged(const QModelIndex &current, const QModelIndex &previous);