[tor-commits] [vidalia/alpha] Provide icon capabilities for plugins menus

chiiph at torproject.org chiiph at torproject.org
Sat Jul 21 19:17:47 UTC 2012


commit f51382526e73fd1b34208d2077d0fbc058283865
Author: Tomás Touceda <chiiph at torproject.org>
Date:   Sat Jul 21 15:50:07 2012 -0300

    Provide icon capabilities for plugins menus
---
 changes/pluginEngineImprovements     |    1 +
 src/vidalia/plugin/PluginWrapper.cpp |   15 ++++++++++++++-
 src/vidalia/plugin/PluginWrapper.h   |    2 ++
 3 files changed, 17 insertions(+), 1 deletions(-)

diff --git a/changes/pluginEngineImprovements b/changes/pluginEngineImprovements
index a242f84..552792a 100644
--- a/changes/pluginEngineImprovements
+++ b/changes/pluginEngineImprovements
@@ -1,3 +1,4 @@
   Internal cleanups and improvements:
   o VidaliaTab prototype for plugins has been migrated to a full QWidget
     derived object and an automatically generated extension.
+  o Provide a way to add icons to a plugin's menu item.
diff --git a/src/vidalia/plugin/PluginWrapper.cpp b/src/vidalia/plugin/PluginWrapper.cpp
index 15634b5..a2c16ea 100644
--- a/src/vidalia/plugin/PluginWrapper.cpp
+++ b/src/vidalia/plugin/PluginWrapper.cpp
@@ -107,6 +107,10 @@ PluginWrapper::processInfo(const QString &path)
         }
       } else if(e.tagName() == "namespace") {
         _nspace = e.text();
+      } else if(e.tagName() == "icon") {
+        _icon = e.text();
+        if(not _icon.startsWith(":"))
+          _icon = QFileInfo(path).absoluteDir().canonicalPath() + "/" + _icon;
       }
     }
     n = n.nextSibling();
@@ -215,10 +219,19 @@ PluginWrapper::files() const
   return _files;
 }
 
+QString
+PluginWrapper::icon() const
+{
+  return _icon;
+}
+
 QAction *
 PluginWrapper::menuAction()
 {
-  _action = new QAction(_name, this);
+  if (not _icon.isEmpty())
+    _action = new QAction(QIcon(_icon), _name, this);
+  else
+    _action = new QAction(_name, this);
 
   if(hasGUI()) {
     connect(_action, SIGNAL(triggered()), this, SLOT(emitPluginTab()));
diff --git a/src/vidalia/plugin/PluginWrapper.h b/src/vidalia/plugin/PluginWrapper.h
index 288c62f..c59ffd2 100644
--- a/src/vidalia/plugin/PluginWrapper.h
+++ b/src/vidalia/plugin/PluginWrapper.h
@@ -36,6 +36,7 @@ class PluginWrapper : public QObject {
     QString date() const;
     QString author() const;
     QString nspace() const;
+    QString icon() const;
     QStringList files() const;
 
     QAction *menuAction();
@@ -60,6 +61,7 @@ class PluginWrapper : public QObject {
     bool _persistent, _gui;
     QStringList _files;
     QString _nspace;
+    QString _icon;
 
     QAction *_action;
 };





More information about the tor-commits mailing list