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

[vidalia-svn] r1701: Make double-clicking on the tray icon bring the main window (in trunk: . src/gui src/gui/res src/gui/res/16x16 src/gui/tray)



Author: edmanm
Date: 2007-04-08 23:12:06 -0400 (Sun, 08 Apr 2007)
New Revision: 1701

Added:
   trunk/src/gui/res/16x16/preferences-desktop.png
Modified:
   trunk/
   trunk/src/gui/mainwindow.cpp
   trunk/src/gui/mainwindow.h
   trunk/src/gui/res/vidalia_common.qrc
   trunk/src/gui/tray/trayicon.h
Log:
 r1785@adrastea:  edmanm | 2007-04-08 23:06:14 -0400
 Make double-clicking on the tray icon bring the main window back, and add a
 "Control Panel" item to the tray menu or OS X menubar.



Property changes on: trunk
___________________________________________________________________
 svk:merge ticket from /vidalia/local/trunk [r1785] on 54b3572a-7227-0410-958f-53ecd705b71a

Modified: trunk/src/gui/mainwindow.cpp
===================================================================
--- trunk/src/gui/mainwindow.cpp	2007-04-09 01:51:15 UTC (rev 1700)
+++ trunk/src/gui/mainwindow.cpp	2007-04-09 03:12:06 UTC (rev 1701)
@@ -41,6 +41,7 @@
 
 #define IMG_APP_ICON       ":/images/16x16/tor-logo.png"
 #define IMG_BWGRAPH        ":/images/16x16/utilities-system-monitor.png"
+#define IMG_CONTROL_PANEL  ":/images/16x16/preferences-desktop.png"
 #define IMG_MESSAGELOG     ":/images/16x16/format-justify-fill.png"
 #define IMG_CONFIG         ":/images/16x16/preferences-system.png"
 #define IMG_IDENTITY       ":/images/16x16/system-users.png"
@@ -132,7 +133,7 @@
   connect(_torControl, SIGNAL(disconnected()), this, SLOT(disconnected()));
   connect(_torControl, SIGNAL(connectFailed(QString)), 
                  this,   SLOT(connectFailed(QString)));
-
+ 
   /* Make sure we shut down when the operating system is restarting */
   connect(vApp, SIGNAL(shutdown()), this, SLOT(shutdown()));
 
@@ -230,6 +231,10 @@
   connect(ui.lblViewNetwork, SIGNAL(clicked()),
           _netViewer, SLOT(showWindow()));
 
+  _controlPanelAct = new QAction(QIcon(IMG_CONTROL_PANEL), 
+                                 tr("Control Panel"), this);
+  connect(_controlPanelAct, SIGNAL(triggered()), this, SLOT(show()));
+
   _configAct = new QAction(QIcon(IMG_CONFIG), tr("Settings"), this);
   connect(_configAct, SIGNAL(triggered()), this, SLOT(showConfigDialog()));
   
@@ -256,6 +261,13 @@
   _trayIcon.setContextMenu(createTrayMenu());
   /* Make the tray icon visible */
   _trayIcon.show();
+
+#if defined(USE_QSYSTEMTRAYICON)
+  connect(&_trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
+                this, SLOT(trayActivated(QSystemTrayIcon::ActivationReason)));
+#else
+  connect(&_trayIcon, SIGNAL(doubleClicked()), this, SLOT(show()));
+#endif
 }
 
 /** Creates a QMenu object that contains QActions which compose the system 
@@ -266,6 +278,7 @@
   QMenu *menu = new QMenu(this);
   menu->addAction(_startStopAct);
   menu->addSeparator();
+  menu->addAction(_controlPanelAct);
   menu->addAction(_bandwidthAct);
   menu->addAction(_messageAct);
   menu->addAction(_networkAct);
@@ -300,6 +313,7 @@
   _networkAct->setShortcut(tr("Ctrl+N"));
   _helpAct->setShortcut(tr("Ctrl+?"));
   _newIdentityAct->setShortcut(tr("Ctrl+I"));
+  _controlPanelAct->setShortcut(tr("Ctrl+P"));
 
   /* Force Qt to put merge the Exit, Configure, and About menubar options into
    * the default menu, even if Vidalia is currently not speaking English. */
@@ -319,6 +333,8 @@
   torMenu->addAction(_newIdentityAct);
 
   QMenu *viewMenu = menuBar->addMenu(tr("View"));
+  viewMenu->addAction(_controlPanelAct);
+  viewMenu->addSeparator();
   viewMenu->addAction(_bandwidthAct);
   viewMenu->addAction(_messageAct);
   viewMenu->addAction(_networkAct);
@@ -395,6 +411,16 @@
   ui.lblTorStatusImg->setPixmap(QPixmap(statusIconFile));
 }
 
+#if defined(USE_QSYSTEMTRAYICON)
+/** Displays the main window if <b>reason</b> is DoubleClick. */
+void
+MainWindow::trayActivated(QSystemTrayIcon::ActivationReason reason)
+{
+  if (reason == QSystemTrayIcon::DoubleClick)
+    show();
+}
+#endif
+
 /** Starts Tor if it is not currently running, or stops Tor if it is already
  * running. */
 void

Modified: trunk/src/gui/mainwindow.h
===================================================================
--- trunk/src/gui/mainwindow.h	2007-04-09 01:51:15 UTC (rev 1700)
+++ trunk/src/gui/mainwindow.h	2007-04-09 03:12:06 UTC (rev 1701)
@@ -36,16 +36,12 @@
  * that won't appear until Qt 4.2.2. */
 #if QT_VERSION >= 0x040200 && !defined(Q_WS_MAC)
 #define USE_QSYSTEMTRAYICON  1
+#include <QSystemTrayIcon>
 #else
 #undef USE_QSYSTEMTRAYICON
+#include "tray/trayicon.h"
 #endif
  
-#if defined(USE_QSYSTEMTRAYICON)
-#include <QSystemTrayIcon>
-#else
-#include "tray/trayicon.h"
-#endif
-
 #include "about/aboutdialog.h"
 #include "log/messagelog.h"
 #include "bwgraph/bwgraph.h"
@@ -102,7 +98,12 @@
   void showConfigDialog(ConfigDialog::Page page = ConfigDialog::General);
   /** Displays the Configuration dialog, set to the Server page. */
   void showServerConfigDialog();
-  
+
+#if defined(USE_QSYSTEMTRAYICON)
+  /** Displays the main window if <b>reason</b> is DoubleClick. */
+  void trayActivated(QSystemTrayIcon::ActivationReason reason);
+#endif
+
 private:
   enum TorStatus {
     Stopped,  /**< Tor is not running. */
@@ -144,6 +145,7 @@
 #endif
   
   /** Defines the actions for the tray menu */
+  QAction* _controlPanelAct;
   QAction* _startStopAct;
   QAction* _configAct;
   QAction* _aboutAct;

Added: trunk/src/gui/res/16x16/preferences-desktop.png
===================================================================
(Binary files differ)


Property changes on: trunk/src/gui/res/16x16/preferences-desktop.png
___________________________________________________________________
Name: svn:mime-type
   + image/x-png

Modified: trunk/src/gui/res/vidalia_common.qrc
===================================================================
--- trunk/src/gui/res/vidalia_common.qrc	2007-04-09 01:51:15 UTC (rev 1700)
+++ trunk/src/gui/res/vidalia_common.qrc	2007-04-09 03:12:06 UTC (rev 1701)
@@ -20,6 +20,7 @@
         <file>16x16/msg-notice.png</file>
         <file>16x16/msg-warn.png</file>
         <file>16x16/network-offline.png</file>
+        <file>16x16/preferences-desktop.png</file>
         <file>16x16/preferences-system.png</file>
         <file>16x16/start-tor.png</file>
         <file>16x16/stop-tor.png</file>

Modified: trunk/src/gui/tray/trayicon.h
===================================================================
--- trunk/src/gui/tray/trayicon.h	2007-04-09 01:51:15 UTC (rev 1700)
+++ trunk/src/gui/tray/trayicon.h	2007-04-09 03:12:06 UTC (rev 1701)
@@ -43,7 +43,7 @@
 #endif
 
 
-class TrayIcon : private TrayIconImpl
+class TrayIcon : public TrayIconImpl
 {
   Q_OBJECT