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

[tor-commits] [vidalia/alpha] Provide the MainWindow to display messages in the app tray icon from plugins



commit 106105ed03aad597e441cfd897ab909d84d847f2
Author: Tomás Touceda <chiiph@xxxxxxxxxxxxxx>
Date:   Wed Mar 21 13:29:22 2012 -0300

    Provide the MainWindow to display messages in the app tray icon from plugins
---
 src/vidalia/MainWindow.cpp          |   12 +++++++++++-
 src/vidalia/MainWindow.h            |    5 ++++-
 src/vidalia/plugin/PluginEngine.cpp |    8 ++++++--
 src/vidalia/plugin/PluginEngine.h   |    3 ++-
 4 files changed, 23 insertions(+), 5 deletions(-)

diff --git a/src/vidalia/MainWindow.cpp b/src/vidalia/MainWindow.cpp
index 20959fc..c0321d5 100644
--- a/src/vidalia/MainWindow.cpp
+++ b/src/vidalia/MainWindow.cpp
@@ -113,6 +113,8 @@ MainWindow::MainWindow()
   _torControl = Vidalia::torControl();
 
   _engine = new PluginEngine();
+  _engine->provide("VidaliaMainWindow", this);
+  _engine->loadAllPlugins();
 
   _dummy = new QAction(tr("No dettached tabs"), this);
 
@@ -447,7 +449,7 @@ MainWindow::createConnections()
   connect(&_updateTimer, SIGNAL(timeout()), this, SLOT(checkForUpdates()));
 
   /* Also check for updates in the foreground when the user clicks the
-   * "Check Now" button in the config dialog. */
+   * "check Now" button in the config dialog. */
   connect(_configDialog, SIGNAL(checkForUpdates()),
           this, SLOT(checkForUpdatesWithUi()));
 
@@ -2228,3 +2230,11 @@ MainWindow::panic()
   }
   vApp->quit();
 }
+
+/** Display a message in the application system tray icon */
+void
+MainWindow::trayMessage(const QString &title, const QString &msg,
+                        QSystemTrayIcon::MessageIcon icon, int milli)
+{
+  _trayIcon.showMessage(title, msg, icon, milli);
+}
diff --git a/src/vidalia/MainWindow.h b/src/vidalia/MainWindow.h
index db9b7e1..5acd2ee 100644
--- a/src/vidalia/MainWindow.h
+++ b/src/vidalia/MainWindow.h
@@ -55,6 +55,10 @@ public:
 public slots:
   /** Shows or hides this window. **/
   virtual void setVisible(bool visible);
+  /** Display a message in the application system tray icon */
+  void trayMessage(const QString &title, const QString &msg,
+                   QSystemTrayIcon::MessageIcon icon = QSystemTrayIcon::Information,
+                   int milli = 10000);
 
 protected:
   /** Called when the user changes the UI translation. */
@@ -318,4 +322,3 @@ private:
 };
 
 #endif
-
diff --git a/src/vidalia/plugin/PluginEngine.cpp b/src/vidalia/plugin/PluginEngine.cpp
index 8fb2833..a263753 100644
--- a/src/vidalia/plugin/PluginEngine.cpp
+++ b/src/vidalia/plugin/PluginEngine.cpp
@@ -44,8 +44,6 @@ PluginEngine::PluginEngine(QObject *parent)
   DebugDialog::outputDebug("Available extensions:");
   foreach(QString ext, availableExtensions())
     DebugDialog::outputDebug(QString("  %1").arg(ext));
-
-  loadAllPlugins();
 }
 
 PluginEngine::~PluginEngine()
@@ -77,6 +75,12 @@ PluginEngine::loadAllPlugins()
 }
 
 void
+PluginEngine::provide(const QString &name, QObject *obj)
+{
+  globalObject().setProperty(name, newQObject(obj));
+}
+
+void
 PluginEngine::tryLoadPlugin(QDir path)
 {
   QStringList files = path.entryList();
diff --git a/src/vidalia/plugin/PluginEngine.h b/src/vidalia/plugin/PluginEngine.h
index 605f3c6..debede3 100644
--- a/src/vidalia/plugin/PluginEngine.h
+++ b/src/vidalia/plugin/PluginEngine.h
@@ -39,7 +39,9 @@ class PluginEngine : public QScriptEngine {
     PluginEngine(QObject *parent = 0);
     ~PluginEngine();
 
+    void loadAllPlugins();
     QList<QAction *> getAllActions();
+    void provide(const QString &name, QObject *obj);
 
   signals:
     void pluginTab(VidaliaTab *);
@@ -52,7 +54,6 @@ class PluginEngine : public QScriptEngine {
     static QScriptValue findWidget(QScriptContext *context, QScriptEngine *engine);
     static QScriptValue sleep(QScriptContext *context, QScriptEngine *engine);
 
-    void loadAllPlugins();
     void tryLoadPlugin(QDir path);
 
     QList<PluginWrapper *> wrappers;



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits