[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[vidalia-svn] r2138: Respond to the Delete key in the network map by closing what (in trunk: . src/gui/network)



Author: edmanm
Date: 2007-11-25 01:22:48 -0500 (Sun, 25 Nov 2007)
New Revision: 2138

Modified:
   trunk/
   trunk/CHANGELOG
   trunk/src/gui/network/circuitlistwidget.cpp
   trunk/src/gui/network/circuitlistwidget.h
Log:
 r2157@lysithea:  edmanm | 2007-11-25 01:22:06 -0500
 Respond to the Delete key in the network map by closing whatever circuits
 or streams are currently selected. Suggested by Andrew Lewman.



Property changes on: trunk
___________________________________________________________________
 svk:merge ticket from /local/vidalia/trunk [r2157] on 0108964c-5b0b-4c9e-969f-e2288315d100

Modified: trunk/CHANGELOG
===================================================================
--- trunk/CHANGELOG	2007-11-24 21:01:47 UTC (rev 2137)
+++ trunk/CHANGELOG	2007-11-25 06:22:48 UTC (rev 2138)
@@ -1,3 +1,8 @@
+0.1.0   xx-xxx-200x
+  o Respond to the Delete key in the network map by closing whatever circuits
+    or streams are currently selected. Suggested by Andrew Lewman.
+
+
 0.0.16  22-Nov-2007
   o Fix compilation on Mac OS X 10.3 (Panther).
   o GETCONF RelayBandwidthRate and RelayBandwidthBurst properly on Tor >=

Modified: trunk/src/gui/network/circuitlistwidget.cpp
===================================================================
--- trunk/src/gui/network/circuitlistwidget.cpp	2007-11-24 21:01:47 UTC (rev 2137)
+++ trunk/src/gui/network/circuitlistwidget.cpp	2007-11-25 06:22:48 UTC (rev 2138)
@@ -27,6 +27,7 @@
 
 #include <QPoint>
 #include <QTimer>
+#include <vidalia.h>
 
 #include "circuitlistwidget.h"
 
@@ -51,6 +52,11 @@
           this, SLOT(onSelectionChanged(QTreeWidgetItem*,QTreeWidgetItem*)));
   connect(this, SIGNAL(customContextMenuRequested(QPoint)),
           this, SLOT(customContextMenuRequested(QPoint)));
+
+  /* Respond to the Delete key by closing whatever circuits or streams are
+   * selected. */
+  vApp->createShortcut(QKeySequence::Delete, this, this,
+                       SLOT(closeSelectedConnections()));
 }
 
 /** Called when the user requests a context menu on a circuit or stream in the
@@ -73,8 +79,10 @@
       return;
 
     /* Set up the circuit context menu */
-    QAction *zoomAct  = new QAction(QIcon(IMG_ZOOM),tr("Zoom to Circuit"),this);
-    QAction *closeAct = new QAction(QIcon(IMG_CLOSE), tr("Close Circuit"),this);
+    QAction *zoomAct  = new QAction(QIcon(IMG_ZOOM),
+                                    tr("Zoom to Circuit"), this);
+    QAction *closeAct = new QAction(QIcon(IMG_CLOSE),
+                                    tr("Close Circuit (Del)"), this);
     zoomAct->setEnabled(circuitItem->circuit().status() == Circuit::Built);
     menu.addAction(zoomAct);
     menu.addSeparator();
@@ -94,7 +102,8 @@
       return;
  
     /* Set up the stream context menu */
-    QAction *closeAct = new QAction(QIcon(IMG_CLOSE), tr("Close Stream"), this);
+    QAction *closeAct = new QAction(QIcon(IMG_CLOSE),
+                                    tr("Close Stream (Del)"), this);
     menu.addAction(closeAct);
 
     /* Display the context menu and find out which (if any) action was
@@ -105,6 +114,24 @@
   }
 }
 
+/** Closes all selected circuits or streams. */
+void
+CircuitListWidget::closeSelectedConnections()
+{
+  QList<QTreeWidgetItem *> items = selectedItems();
+  foreach (QTreeWidgetItem *item, items) {
+    if (!item->parent()) {
+      CircuitItem *circuitItem = dynamic_cast<CircuitItem *>(item);
+      if (circuitItem)
+        emit closeCircuit(circuitItem->id());
+    } else {
+      StreamItem *streamItem = dynamic_cast<StreamItem *>(item);
+      if (streamItem)
+        emit closeStream(streamItem->id());
+    }
+  }
+}
+
 /** Adds a circuit to the list. If the circuit already exists in the list, the
  * status and path will be updated. <b>displayedPath</b> contains a
  * description of the circuit's path suitable for humans to read. */

Modified: trunk/src/gui/network/circuitlistwidget.h
===================================================================
--- trunk/src/gui/network/circuitlistwidget.h	2007-11-24 21:01:47 UTC (rev 2137)
+++ trunk/src/gui/network/circuitlistwidget.h	2007-11-25 06:22:48 UTC (rev 2138)
@@ -88,6 +88,8 @@
    * the list and displays a context menu appropriate for whichever type of
    * item is currently selected. */
   void customContextMenuRequested(const QPoint &pos);
+  /** Closes all selected circuits or streams. */
+  void closeSelectedConnections();
 
 private:
   /** Removes the given circuit item and all streams on that circuit. */