From 9f33f6e471dedbefe7bbe336a40312894628afe1 Mon Sep 17 00:00:00 2001 From: Chris Le Sueur Date: Tue, 2 Aug 2011 17:10:34 +0100 Subject: [PATCH] Add a shortcut for hiding current buffer. --- src/qtui/mainwin.cpp | 8 ++++++++ src/qtui/mainwin.h | 1 + src/uisupport/bufferview.cpp | 20 ++++++++++++++++++++ src/uisupport/bufferview.h | 1 + 4 files changed, 30 insertions(+) diff --git a/src/qtui/mainwin.cpp b/src/qtui/mainwin.cpp index 5d50acca..f40aa9c9 100644 --- a/src/qtui/mainwin.cpp +++ b/src/qtui/mainwin.cpp @@ -456,6 +456,8 @@ void MainWin::setupActions() { this, SLOT(nextBuffer()), QKeySequence(Qt::ALT + Qt::Key_Down))); coll->addAction("PreviousBuffer", new Action(SmallIcon("go-up"), tr("Go to Previous Chat"), coll, this, SLOT(previousBuffer()), QKeySequence(Qt::ALT + Qt::Key_Up))); + coll->addAction("HideCurrentBuffer", new Action(tr("Hide Current Buffer"), coll, + this, SLOT(hideCurrentBuffer()), QKeySequence(Qt::ControlModifier + Qt::Key_W))); } void MainWin::setupMenus() { @@ -713,6 +715,12 @@ void MainWin::previousBuffer() { view->previousBuffer(); } +void MainWin::hideCurrentBuffer() { + BufferView *view = activeBufferView(); + if(view) + view->hideCurrentBuffer(); +} + void MainWin::showNotificationsDlg() { SettingsPageDlg dlg(new NotificationsSettingsPage(this), this); dlg.exec(); diff --git a/src/qtui/mainwin.h b/src/qtui/mainwin.h index a1fa4443..49b49d70 100644 --- a/src/qtui/mainwin.h +++ b/src/qtui/mainwin.h @@ -85,6 +85,7 @@ class MainWin public slots: void showStatusBarMessage(const QString &message); + void hideCurrentBuffer(); void nextBufferView(); //!< Activate the next bufferview void previousBufferView(); //!< Activate the previous bufferview void nextBuffer(); diff --git a/src/uisupport/bufferview.cpp b/src/uisupport/bufferview.cpp index b5f5a573..7bc359a8 100644 --- a/src/uisupport/bufferview.cpp +++ b/src/uisupport/bufferview.cpp @@ -485,6 +485,26 @@ void BufferView::wheelEvent(QWheelEvent* event) { changeBuffer((Direction)rowDelta); } +void BufferView::hideCurrentBuffer() { + QModelIndex index = selectionModel()->currentIndex(); + if(index.data(NetworkModel::ItemTypeRole) != NetworkModel::BufferItemType) + return; + + BufferId bufferId = index.data(NetworkModel::BufferIdRole).value(); + + //The check above means we won't be looking at a network, which should always be the first row, so we can just go backwards. + changeBuffer(Backward); + + /*if(removedRows.contains(bufferId)) + continue; + + removedRows << bufferId;*/ + /*if(permanently) + config()->requestRemoveBufferPermanently(bufferId); + else*/ + config()->requestRemoveBuffer(bufferId); +} + QSize BufferView::sizeHint() const { return QTreeView::sizeHint(); diff --git a/src/uisupport/bufferview.h b/src/uisupport/bufferview.h index 8eca6756..bbbfe84c 100644 --- a/src/uisupport/bufferview.h +++ b/src/uisupport/bufferview.h @@ -65,6 +65,7 @@ public slots: void menuActionTriggered(QAction *); void nextBuffer(); void previousBuffer(); + void hideCurrentBuffer(); signals: void removeBuffer(const QModelIndex &); -- 2.20.1