aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDeon van der Westhuysen <deonvdw@gmail.com>2015-01-06 10:22:48 +0100
committerGerald Combs <gerald@wireshark.org>2015-01-16 00:27:35 +0000
commit7d43836b3ad54073a98926450ff0bca7bc34ddeb (patch)
treef694828ee0d26aa56d3484942fa498c5eac5b83a
parentd5ee022b9e7cecbacc6433597ac44a140e8354ff (diff)
QT: stats_tree plug-ins not added to statistics menu
Wireshark Qt does not add plug-ins that register with stats_tree_register_plugin() to the statistics menu in the ui (like the gtk version does). This patch dynamically adds all registered stats_tree plug-ins to the statistics menu. Bug: 9528 Change-Id: I99f9415502ca9f7121d494c856861edc1a762079 Signed-off-by: Alexis La Goutte <alexis.lagoutte@gmail.com> Reviewed-on: https://code.wireshark.org/review/6336 Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Gerald Combs <gerald@wireshark.org>
-rw-r--r--ui/qt/main_window.cpp14
-rw-r--r--ui/qt/main_window.h3
-rw-r--r--ui/qt/main_window_slots.cpp44
3 files changed, 61 insertions, 0 deletions
diff --git a/ui/qt/main_window.cpp b/ui/qt/main_window.cpp
index 0201e62bb8..48b418442f 100644
--- a/ui/qt/main_window.cpp
+++ b/ui/qt/main_window.cpp
@@ -26,6 +26,7 @@
#include <epan/epan_dissect.h>
#include <wsutil/filesystem.h>
#include <epan/prefs.h>
+#include <epan/stats_tree_priv.h>
//#include <wiretap/wtap.h>
@@ -143,6 +144,18 @@ vsimple_error_message_box(const char *msg_format, va_list ap)
}
+QMenu* MainWindow::findOrAddMenu(QMenu *parent_menu, QString& menu_text) {
+ QList<QAction *> actions = parent_menu->actions();
+ QList<QAction *>::const_iterator i;
+ for (i = actions.constBegin(); i != actions.constEnd(); ++i) {
+ if ((*i)->text()==menu_text) {
+ return (*i)->menu();
+ }
+ }
+ // If we get here there menu entry was not found, add a sub menu
+ return parent_menu->addMenu(menu_text);
+}
+
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
main_ui_(new Ui::MainWindow),
@@ -182,6 +195,7 @@ MainWindow::MainWindow(QWidget *parent) :
setFeaturesEnabled(false);
connect(wsApp, SIGNAL(appInitialized()), this, SLOT(setFeaturesEnabled()));
connect(wsApp, SIGNAL(appInitialized()), this, SLOT(zoomText()));
+ connect(wsApp, SIGNAL(appInitialized()), this, SLOT(addStatsPluginsToMenu()));
connect(wsApp, SIGNAL(preferencesChanged()), this, SLOT(layoutPanes()));
connect(wsApp, SIGNAL(preferencesChanged()), this, SLOT(layoutToolbars()));
diff --git a/ui/qt/main_window.h b/ui/qt/main_window.h
index 38d02bd745..b254f4214e 100644
--- a/ui/qt/main_window.h
+++ b/ui/qt/main_window.h
@@ -171,6 +171,7 @@ private:
void setMenusForFileSet(bool enable_list_files);
void setForCaptureInProgress(gboolean capture_in_progress = false);
+ QMenu* findOrAddMenu(QMenu *parent_menu, QString& menu_text);
signals:
void showProgress(progdlg_t **dlg_p, bool animate, const QString message, bool terminate_is_stop, bool *stop_flag, float pct);
@@ -225,6 +226,7 @@ private slots:
void recreatePacketList();
void fieldsChanged();
void showColumnEditor(int column);
+ void addStatsPluginsToMenu();
void startInterfaceCapture(bool valid);
@@ -420,6 +422,7 @@ private slots:
void on_actionStatisticsIOGraph_triggered();
void on_actionStatisticsSametime_triggered();
void on_actionStatisticsDNS_triggered();
+ void actionStatisticsPlugin_triggered();
void openVoipCallsDialog(bool all_flows = false);
void on_actionTelephonyVoipCalls_triggered();
diff --git a/ui/qt/main_window_slots.cpp b/ui/qt/main_window_slots.cpp
index 9e55dc46d6..00df4a6c46 100644
--- a/ui/qt/main_window_slots.cpp
+++ b/ui/qt/main_window_slots.cpp
@@ -1288,6 +1288,42 @@ void MainWindow::showColumnEditor(int column)
main_ui_->columnEditorFrame->animatedShow();
}
+void MainWindow::addStatsPluginsToMenu() {
+ GList *cfg_list = stats_tree_get_cfg_list();
+ GList *iter = g_list_first(cfg_list);
+ QAction *stats_tree_action;
+ QMenu *parent_menu;
+ bool first_item = true;
+
+ while (iter) {
+ stats_tree_cfg *cfg = (stats_tree_cfg*)iter->data;
+ if (cfg->plugin) {
+ if (first_item) {
+ main_ui_->menuStatistics->addSeparator();
+ first_item = false;
+ }
+
+ parent_menu = main_ui_->menuStatistics;
+ // gtk/main_menubar.c compresses double slashes, hence SkipEmptyParts
+ QStringList cfg_name_parts = QString(cfg->name).split("/", QString::SkipEmptyParts);
+ if (cfg_name_parts.isEmpty()) continue;
+
+ QString stat_name = cfg_name_parts.takeLast();
+ if (!cfg_name_parts.isEmpty()) {
+ QString menu_name = cfg_name_parts.join("/");
+ parent_menu = findOrAddMenu(parent_menu, menu_name);
+ }
+
+ stats_tree_action = new QAction(stat_name, this);
+ stats_tree_action->setData(cfg->abbr);
+ parent_menu->addAction(stats_tree_action);
+ connect(stats_tree_action, SIGNAL(triggered()), this, SLOT(actionStatisticsPlugin_triggered()));
+ }
+ iter = g_list_next(iter);
+ }
+ g_list_free(cfg_list);
+}
+
void MainWindow::setFeaturesEnabled(bool enabled)
{
main_ui_->menuBar->setEnabled(enabled);
@@ -2392,6 +2428,14 @@ void MainWindow::on_actionStatisticsDNS_triggered()
openStatisticsTreeDialog("dns");
}
+void MainWindow::actionStatisticsPlugin_triggered()
+{
+ QAction* action = qobject_cast<QAction*>(sender());
+ if(action) {
+ openStatisticsTreeDialog(action->data().toString().toUtf8());
+ }
+}
+
// Telephony Menu
void MainWindow::openVoipCallsDialog(bool all_flows)