From a35e9270e608bfbc5b21ba47d49b3139f06b13e9 Mon Sep 17 00:00:00 2001 From: Manuel Nickschas Date: Sun, 11 Jan 2009 12:02:26 +0100 Subject: [PATCH] Properly focus BufferView on first click 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 | 5 +++++ src/uisupport/bufferview.cpp | 6 ++++++ src/uisupport/bufferview.h | 1 + 3 files changed, 12 insertions(+) diff --git a/src/qtui/mainwin.h b/src/qtui/mainwin.h index 0d29393a..cc8d8d12 100644 --- a/src/qtui/mainwin.h +++ b/src/qtui/mainwin.h @@ -66,6 +66,7 @@ class MainWin BufferView *allBuffersView() const; inline QSystemTrayIcon *systemTrayIcon() const; + inline BufferWidget *bufferWidget() const; virtual bool event(QEvent *event); @@ -167,4 +168,8 @@ QSystemTrayIcon *MainWin::systemTrayIcon() const { return _trayIcon; } +BufferWidget *MainWin::bufferWidget() const { + return _bufferWidget; +} + #endif diff --git a/src/uisupport/bufferview.cpp b/src/uisupport/bufferview.cpp index c06e7d20..74552696 100644 --- a/src/uisupport/bufferview.cpp +++ b/src/uisupport/bufferview.cpp @@ -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(clicked(const QModelIndex &)), SLOT(on_clicked(const QModelIndex &))); setSelectionMode(QAbstractItemView::ExtendedSelection); @@ -354,6 +355,11 @@ void BufferView::on_configChanged() { 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(), false); } diff --git a/src/uisupport/bufferview.h b/src/uisupport/bufferview.h index 4e83369e..12bb9024 100644 --- a/src/uisupport/bufferview.h +++ b/src/uisupport/bufferview.h @@ -78,6 +78,7 @@ private slots: void on_collapse(const QModelIndex &index); void on_expand(const QModelIndex &index); + void on_clicked(const QModelIndex &index); void on_configChanged(); private: -- 2.20.1