Properly focus BufferView on first click
authorManuel Nickschas <sputnick@quassel-irc.org>
Sun, 11 Jan 2009 11:02:26 +0000 (12:02 +0100)
committerManuel Nickschas <sputnick@quassel-irc.org>
Sun, 11 Jan 2009 11:45:20 +0000 (12:45 +0100)
Now you don't need to click in a BufferView twice anymore to gain keyboard focus,
for example for hiding a buffer per pressing backspace.
Side-effect is that the input line loses focus now when clicking in the view (obviously),
but the next commmit focuses it automatically on key press, so it should be smooth that way.

src/qtui/mainwin.h
src/uisupport/bufferview.cpp
src/uisupport/bufferview.h

index 0d29393..cc8d8d1 100644 (file)
@@ -66,6 +66,7 @@ class MainWin
     BufferView *allBuffersView() const;
 
     inline QSystemTrayIcon *systemTrayIcon() const;
     BufferView *allBuffersView() const;
 
     inline QSystemTrayIcon *systemTrayIcon() const;
+    inline BufferWidget *bufferWidget() const;
 
     virtual bool event(QEvent *event);
 
 
     virtual bool event(QEvent *event);
 
@@ -167,4 +168,8 @@ QSystemTrayIcon *MainWin::systemTrayIcon() const {
   return _trayIcon;
 }
 
   return _trayIcon;
 }
 
+BufferWidget *MainWin::bufferWidget() const {
+  return _bufferWidget;
+}
+
 #endif
 #endif
index c06e7d2..7455269 100644 (file)
@@ -86,6 +86,7 @@ BufferView::BufferView(QWidget *parent)
 {
   connect(this, SIGNAL(collapsed(const QModelIndex &)), SLOT(on_collapse(const QModelIndex &)));
   connect(this, SIGNAL(expanded(const QModelIndex &)), SLOT(on_expand(const QModelIndex &)));
 {
   connect(this, SIGNAL(collapsed(const QModelIndex &)), SLOT(on_collapse(const QModelIndex &)));
   connect(this, SIGNAL(expanded(const QModelIndex &)), SLOT(on_expand(const QModelIndex &)));
+  connect(this, SIGNAL(clicked(const QModelIndex &)), SLOT(on_clicked(const QModelIndex &)));
 
   setSelectionMode(QAbstractItemView::ExtendedSelection);
 
 
   setSelectionMode(QAbstractItemView::ExtendedSelection);
 
@@ -354,6 +355,11 @@ void BufferView::on_configChanged() {
   return;
 }
 
   return;
 }
 
+void BufferView::on_clicked(const QModelIndex &index) {
+  Q_UNUSED(index);
+  setFocus(Qt::MouseFocusReason);
+}
+
 void BufferView::on_collapse(const QModelIndex &index) {
   storeExpandedState(index.data(NetworkModel::NetworkIdRole).value<NetworkId>(), false);
 }
 void BufferView::on_collapse(const QModelIndex &index) {
   storeExpandedState(index.data(NetworkModel::NetworkIdRole).value<NetworkId>(), false);
 }
index 4e83369..12bb902 100644 (file)
@@ -78,6 +78,7 @@ private slots:
 
   void on_collapse(const QModelIndex &index);
   void on_expand(const QModelIndex &index);
 
   void on_collapse(const QModelIndex &index);
   void on_expand(const QModelIndex &index);
+  void on_clicked(const QModelIndex &index);
   void on_configChanged();
 
 private:
   void on_configChanged();
 
 private: