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

[vidalia-svn] r2006: Give arma not one, not two, but three (yes folks, three) way (in trunk: . src/gui/config)



Author: edmanm
Date: 2007-10-11 23:42:41 -0400 (Thu, 11 Oct 2007)
New Revision: 2006

Modified:
   trunk/
   trunk/src/gui/config/networkpage.cpp
   trunk/src/gui/config/networkpage.h
   trunk/src/gui/config/networkpage.ui
Log:
 r2072@lysithea:  edmanm | 2007-10-11 23:41:58 -0400
 Give arma not one, not two, but three (yes folks, three) ways of copying
 bridge information to the clipboard. Users can select one or more bridges and
 then either (1) Press Ctrl+C, (2) Right-click and select "Copy" from a context
 menu, or (3) Click the shiny new Copy button next to the bridge list, to copy
 their bridges to the clipboard.



Property changes on: trunk
___________________________________________________________________
 svk:merge ticket from /local/vidalia/trunk [r2072] on dc66be73-d13e-47ba-a267-8dc7cda68c65

Modified: trunk/src/gui/config/networkpage.cpp
===================================================================
--- trunk/src/gui/config/networkpage.cpp	2007-10-12 03:42:33 UTC (rev 2005)
+++ trunk/src/gui/config/networkpage.cpp	2007-10-12 03:42:41 UTC (rev 2006)
@@ -25,14 +25,18 @@
  * \brief Network and firewall configuration options
  */
 
+#include <QMenu>
 #include <QIntValidator>
+#include <QClipboard>
 #include <networksettings.h>
 #include <vidalia.h>
 
 #include "networkpage.h"
 #include "domainvalidator.h"
 
+#define IMG_COPY  ":/images/22x22/edit-copy.png"
 
+
 /** Constructor */
 NetworkPage::NetworkPage(QWidget *parent)
 : ConfigPage(parent, tr("Network"))
@@ -42,9 +46,19 @@
  
   connect(ui.btnAddBridge, SIGNAL(clicked()), this, SLOT(addBridge()));
   connect(ui.btnRemoveBridge, SIGNAL(clicked()), this, SLOT(removeBridge()));
+  connect(ui.btnCopyBridge, SIGNAL(clicked()), 
+          this, SLOT(copySelectedBridgesToClipboard()));
+  connect(ui.listBridges, SIGNAL(customContextMenuRequested(QPoint)),
+          this, SLOT(bridgeContextMenuRequested(QPoint)));
+  connect(ui.listBridges, SIGNAL(itemSelectionChanged()),
+          this, SLOT(bridgeSelectionChanged()));
 
   ui.lineHttpProxyAddress->setValidator(new DomainValidator(this));
   ui.lineHttpProxyPort->setValidator(new QIntValidator(1, 65535, this));
+
+  vApp->createShortcut(QKeySequence(QKeySequence::Copy),
+                       ui.listBridges, this,
+                       SLOT(copySelectedBridgesToClipboard()));
 }
 
 /** Applies the network configuration settings to Tor. Returns true if the   *
@@ -95,6 +109,50 @@
   qDeleteAll(ui.listBridges->selectedItems());
 }
 
+/** Copies all selected bridges to the clipboard. */
+void
+NetworkPage::copySelectedBridgesToClipboard()
+{
+  QString contents;
+
+  foreach (QListWidgetItem *item, ui.listBridges->selectedItems()) {
+#if defined(Q_WS_WIN)
+    contents += item->text() + "\r\n";
+#else
+    contents += item->text() + "\n";
+#endif
+  }
+  if (!contents.isEmpty())
+    vApp->clipboard()->setText(contents.trimmed());
+}
+
+/** Called when the user right-clicks on a bridge and displays a context
+ * menu. */
+void
+NetworkPage::bridgeContextMenuRequested(const QPoint &pos)
+{
+  QMenu menu(this);
+  
+  QListWidgetItem *item = ui.listBridges->itemAt(pos);
+  if (!item)
+    return;
+  
+  QAction *copyAction =
+    new QAction(QIcon(IMG_COPY), tr("Copy (Ctrl+C)"), &menu);
+  connect(copyAction, SIGNAL(triggered()),
+          this, SLOT(copySelectedBridgesToClipboard()));
+
+  menu.addAction(copyAction);
+  menu.exec(ui.listBridges->mapToGlobal(pos));
+}
+
+/** Called when the user changes which bridges they have selected. */
+void
+NetworkPage::bridgeSelectionChanged()
+{
+  ui.btnCopyBridge->setEnabled(!ui.listBridges->selectedItems().isEmpty());
+}
+
 /** Saves changes made to settings on the Firewall settings page. */
 bool
 NetworkPage::save(QString &errmsg)

Modified: trunk/src/gui/config/networkpage.h
===================================================================
--- trunk/src/gui/config/networkpage.h	2007-10-12 03:42:33 UTC (rev 2005)
+++ trunk/src/gui/config/networkpage.h	2007-10-12 03:42:41 UTC (rev 2006)
@@ -28,6 +28,7 @@
 #ifndef _NETWORKPAGE_H
 #define _NETWORKPAGE_H
 
+#include <QPoint>
 #include <vidalia.h>
 
 #include "configpage.h"
@@ -63,6 +64,13 @@
   void addBridge();
   /** Removes one or more selected bridges from the bridge list box. */
   void removeBridge();
+  /** Copies all selected bridges to the clipboard. */
+  void copySelectedBridgesToClipboard();
+  /** Called when the user right-clicks on a bridge and displays a context
+   * menu. */
+  void bridgeContextMenuRequested(const QPoint &pos);
+  /** Called when the user changes which bridges they have selected. */
+  void bridgeSelectionChanged();
 
 private:
   /** Qt Designer generated object */

Modified: trunk/src/gui/config/networkpage.ui
===================================================================
--- trunk/src/gui/config/networkpage.ui	2007-10-12 03:42:33 UTC (rev 2005)
+++ trunk/src/gui/config/networkpage.ui	2007-10-12 03:42:41 UTC (rev 2006)
@@ -309,6 +309,9 @@
           </item>
           <item>
            <widget class="QListWidget" name="listBridges" >
+            <property name="contextMenuPolicy" >
+             <enum>Qt::CustomContextMenu</enum>
+            </property>
             <property name="selectionMode" >
              <enum>QAbstractItemView::ExtendedSelection</enum>
             </property>
@@ -348,6 +351,9 @@
               <height>32</height>
              </size>
             </property>
+            <property name="toolTip" >
+             <string>Remove the selected bridges from the list</string>
+            </property>
             <property name="text" >
              <string/>
             </property>
@@ -357,6 +363,28 @@
            </widget>
           </item>
           <item>
+           <widget class="QPushButton" name="btnCopyBridge" >
+            <property name="enabled" >
+             <bool>false</bool>
+            </property>
+            <property name="maximumSize" >
+             <size>
+              <width>32</width>
+              <height>32</height>
+             </size>
+            </property>
+            <property name="toolTip" >
+             <string>Copy the selected bridges to the clipboard</string>
+            </property>
+            <property name="text" >
+             <string/>
+            </property>
+            <property name="icon" >
+             <iconset resource="../res/vidalia_common.qrc" >:/images/22x22/edit-copy.png</iconset>
+            </property>
+           </widget>
+          </item>
+          <item>
            <spacer>
             <property name="orientation" >
              <enum>Qt::Vertical</enum>