Add a shortcut for hiding current buffer.
authorChris Le Sueur <c.m.lesueur@gmail.com>
Tue, 2 Aug 2011 16:10:34 +0000 (17:10 +0100)
committerManuel Nickschas <sputnick@quassel-irc.org>
Tue, 14 Feb 2012 20:56:49 +0000 (21:56 +0100)
src/qtui/mainwin.cpp
src/qtui/mainwin.h
src/uisupport/bufferview.cpp
src/uisupport/bufferview.h

index 5d50acc..f40aa9c 100644 (file)
@@ -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();
index a1fa444..49b49d7 100644 (file)
@@ -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();
index b5f5a57..7bc359a 100644 (file)
@@ -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<BufferId>();
+  
+  //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();
 
index 8eca675..bbbfe84 100644 (file)
@@ -65,6 +65,7 @@ public slots:
   void menuActionTriggered(QAction *);
   void nextBuffer();
   void previousBuffer();
+  void hideCurrentBuffer();
 
 signals:
   void removeBuffer(const QModelIndex &);