summaryrefslogtreecommitdiff
path: root/ui/qt/main_window.cpp
diff options
context:
space:
mode:
authorRoland Knall <rknall@gmail.com>2015-08-09 14:36:53 +0200
committerAlexis La Goutte <alexis.lagoutte@gmail.com>2015-09-08 11:03:35 +0000
commit6f1c9fd4320804958a8731afc45a1cc6f9ee3b16 (patch)
tree88733bb1ae91072d9c6dac9404074e5afa59cd55 /ui/qt/main_window.cpp
parent28128ca41c299ea859fd59583a12cd767b1af33f (diff)
downloadwireshark-6f1c9fd4320804958a8731afc45a1cc6f9ee3b16.tar.gz
PluginIF: Parent menu and goto frame
The developer may provide a given menu as parent menu for the sub menu. If the menu does not exist, the main menu will be used. Has been implemented for Qt as well as GTK. Change-Id: I3f26684862fd0b08f59eeb4d6f4a24ce7dc3d428 Reviewed-on: https://code.wireshark.org/review/9939 Reviewed-by: Roland Knall <rknall@gmail.com> Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com> Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com> Reviewed-by: Anders Broman <a.broman58@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Diffstat (limited to 'ui/qt/main_window.cpp')
-rw-r--r--ui/qt/main_window.cpp45
1 files changed, 44 insertions, 1 deletions
diff --git a/ui/qt/main_window.cpp b/ui/qt/main_window.cpp
index a1b25ee61a..f3bdc81509 100644
--- a/ui/qt/main_window.cpp
+++ b/ui/qt/main_window.cpp
@@ -121,6 +121,21 @@ static void plugin_if_mainwindow_preference(gconstpointer user_data)
}
}
+void plugin_if_mainwindow_gotoframe(gconstpointer user_data)
+{
+ if ( gbl_cur_main_window_ != NULL && user_data != NULL )
+ {
+ GHashTable * dataSet = (GHashTable *) user_data;
+ gpointer framenr;
+
+ if ( g_hash_table_lookup_extended(dataSet, "frame_nr", NULL, &framenr ) )
+ {
+ if ( GPOINTER_TO_UINT(framenr) != 0 )
+ gbl_cur_main_window_->gotoFrame(GPOINTER_TO_UINT(framenr));
+ }
+ }
+}
+
gpointer
simple_dialog(ESD_TYPE_E type, gint btn_mask, const gchar *msg_format, ...)
{
@@ -568,6 +583,7 @@ MainWindow::MainWindow(QWidget *parent) :
plugin_if_register_gui_cb(PLUGIN_IF_FILTER_ACTION_APPLY, plugin_if_mainwindow_apply_filter );
plugin_if_register_gui_cb(PLUGIN_IF_FILTER_ACTION_PREPARE, plugin_if_mainwindow_apply_filter );
plugin_if_register_gui_cb(PLUGIN_IF_PREFERENCE_SAVE, plugin_if_mainwindow_preference);
+ plugin_if_register_gui_cb(PLUGIN_IF_GOTO_FRAME, plugin_if_mainwindow_gotoframe);
main_ui_->mainStack->setCurrentWidget(main_welcome_);
}
@@ -2203,6 +2219,25 @@ void MainWindow::externalMenuHelper(ext_menu_t * menu, QMenu * subMenu, gint de
}
}
+QMenu * MainWindow::searchSubMenu(QString objectName)
+{
+ QList<QMenu*> lst;
+
+ if ( objectName.length() > 0 )
+ {
+ QString searchName = QString("menu") + objectName;
+
+ lst = main_ui_->menuBar->findChildren<QMenu*>();
+ foreach (QMenu* m, lst)
+ {
+ if ( QString::compare( m->objectName(), searchName ) == 0 )
+ return m;
+ }
+ }
+
+ return 0;
+}
+
void MainWindow::addExternalMenus()
{
QMenu * subMenu = NULL;
@@ -2224,7 +2259,15 @@ void MainWindow::addExternalMenus()
}
/* Create main submenu and add it to the menubar */
- subMenu = main_ui_->menuBar->addMenu(menu->label);
+ if ( menu->parent_menu != NULL )
+ {
+ QMenu * sortUnderneath = searchSubMenu(QString(menu->parent_menu));
+ if ( sortUnderneath != NULL)
+ subMenu = sortUnderneath->addMenu(menu->label);
+ }
+
+ if ( subMenu == NULL )
+ subMenu = main_ui_->menuBar->addMenu(menu->label);
/* This will generate the action structure for each menu. It is recursive,
* therefore a sub-routine, and we have a depth counter to prevent endless loops. */