fixed focus when closing ChatViewSearchbar
[quassel.git] / src / qtui / bufferwidget.cpp
index d9f3bdf..e6990aa 100644 (file)
@@ -1,5 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2005-08 by the Quassel Project                          *
+ *   Copyright (C) 2005-09 by the Quassel Project                          *
  *   devel@quassel-irc.org                                                 *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
@@ -20,6 +20,7 @@
 
 #include <QLayout>
 #include <QKeyEvent>
+#include <QMenu>
 #include <QScrollBar>
 
 #include "action.h"
@@ -30,7 +31,7 @@
 #include "chatviewsearchcontroller.h"
 #include "client.h"
 #include "iconloader.h"
-#include "inputline.h"
+#include "multilineedit.h"
 #include "qtui.h"
 #include "settings.h"
 
@@ -49,23 +50,25 @@ BufferWidget::BufferWidget(QWidget *parent)
   _chatViewSearchController->setSearchMsgs(ui.searchBar->searchMsgsBox()->isChecked());
   _chatViewSearchController->setSearchOnlyRegularMsgs(ui.searchBar->searchOnlyRegularMsgsBox()->isChecked());
 
-  connect(ui.searchBar->searchEditLine(), SIGNAL(textChanged(const QString &)),
-         _chatViewSearchController, SLOT(setSearchString(const QString &)));
+  connect(ui.searchBar, SIGNAL(searchChanged(const QString &)),
+    _chatViewSearchController, SLOT(setSearchString(const QString &)));
   connect(ui.searchBar->caseSensitiveBox(), SIGNAL(toggled(bool)),
-         _chatViewSearchController, SLOT(setCaseSensitive(bool)));
+    _chatViewSearchController, SLOT(setCaseSensitive(bool)));
   connect(ui.searchBar->searchSendersBox(), SIGNAL(toggled(bool)),
-         _chatViewSearchController, SLOT(setSearchSenders(bool)));
+    _chatViewSearchController, SLOT(setSearchSenders(bool)));
   connect(ui.searchBar->searchMsgsBox(), SIGNAL(toggled(bool)),
-         _chatViewSearchController, SLOT(setSearchMsgs(bool)));
+    _chatViewSearchController, SLOT(setSearchMsgs(bool)));
   connect(ui.searchBar->searchOnlyRegularMsgsBox(), SIGNAL(toggled(bool)),
-         _chatViewSearchController, SLOT(setSearchOnlyRegularMsgs(bool)));
+    _chatViewSearchController, SLOT(setSearchOnlyRegularMsgs(bool)));
   connect(ui.searchBar->searchUpButton(), SIGNAL(clicked()),
-         _chatViewSearchController, SLOT(highlightPrev()));
+    _chatViewSearchController, SLOT(highlightPrev()));
   connect(ui.searchBar->searchDownButton(), SIGNAL(clicked()),
-         _chatViewSearchController, SLOT(highlightNext()));
+    _chatViewSearchController, SLOT(highlightNext()));
+
+  connect(ui.searchBar, SIGNAL(hidden()), this, SLOT(setFocus()));
 
   connect(_chatViewSearchController, SIGNAL(newCurrentHighlight(QGraphicsItem *)),
-         this, SLOT(scrollToHighlight(QGraphicsItem *)));
+    this, SLOT(scrollToHighlight(QGraphicsItem *)));
 
   ActionCollection *coll = QtUi::actionCollection();
 
@@ -160,11 +163,12 @@ bool BufferWidget::eventFilter(QObject *watched, QEvent *event) {
 
   QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
 
+  MultiLineEdit *inputLine = qobject_cast<MultiLineEdit *>(watched);
+  if(!inputLine)
+    return false;
+
   // Intercept copy key presses
   if(keyEvent == QKeySequence::Copy) {
-    InputLine *inputLine = qobject_cast<InputLine *>(watched);
-    if(!inputLine)
-      return false;
     if(inputLine->hasSelectedText())
       return false;
     ChatView *view = qobject_cast<ChatView *>(ui.stackedWidget->currentWidget());
@@ -173,6 +177,10 @@ bool BufferWidget::eventFilter(QObject *watched, QEvent *event) {
     return true;
   }
 
+  // We don't want to steal cursor movement keys if the input line is in multiline mode
+  if(!inputLine->isSingleLine())
+    return false;
+
   switch(keyEvent->key()) {
   case Qt::Key_Up:
   case Qt::Key_Down: