From 26dacfc8c3befed5fb6dacd84e7d6107c6920b2e Mon Sep 17 00:00:00 2001 From: Gerald Combs Date: Tue, 16 Jun 2015 17:24:19 -0700 Subject: Qt: Add protocol preferences menus. Add protocol preferences in the packet list and packet detail context menus. Note that we need a PreferencesEditorFrame in the main window for editing numeric and string preferences. For now we just show the prefs dialog. Change-Id: Ice0cc8e9bc25963cc14aa47698f042f2a73088d8 Reviewed-on: https://code.wireshark.org/review/8957 Petri-Dish: Gerald Combs Tested-by: Petri Dish Buildbot Reviewed-by: Gerald Combs --- ui/qt/proto_tree.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'ui/qt/proto_tree.cpp') diff --git a/ui/qt/proto_tree.cpp b/ui/qt/proto_tree.cpp index 2d1b404587..e2848f41f3 100644 --- a/ui/qt/proto_tree.cpp +++ b/ui/qt/proto_tree.cpp @@ -251,8 +251,8 @@ ProtoTree::ProtoTree(QWidget *parent) : // " \n" // " \n" // " \n" -// " \n" -// ctx_menu_.addSeparator(); + ctx_menu_.addMenu(&proto_prefs_menu_); + ctx_menu_.addSeparator(); decode_as_ = window()->findChild("actionAnalyzeDecodeAs"); ctx_menu_.addAction(decode_as_); // " \n" @@ -269,6 +269,9 @@ ProtoTree::ProtoTree(QWidget *parent) : connect(this, SIGNAL(collapsed(QModelIndex)), this, SLOT(collapse(QModelIndex))); connect(this, SIGNAL(itemDoubleClicked(QTreeWidgetItem*, int)), this, SLOT(itemDoubleClick(QTreeWidgetItem*, int))); + + connect(&proto_prefs_menu_, SIGNAL(showProtocolPreferences(QString)), + this, SIGNAL(showProtocolPreferences(QString))); } void ProtoTree::clear() { @@ -286,6 +289,19 @@ void ProtoTree::contextMenuEvent(QContextMenuEvent *event) conv_menu_.addAction(action); } + const char *module_name = NULL; + if (selectedItems().count() > 0) { + field_info *fi = selectedItems()[0]->data(0, Qt::UserRole).value(); + if (fi && fi->hfinfo) { + if (fi->hfinfo->parent == -1) { + module_name = fi->hfinfo->abbrev; + } else { + module_name = proto_registrar_get_abbrev(fi->hfinfo->parent); + } + } + } + proto_prefs_menu_.setModule(module_name); + decode_as_->setData(qVariantFromValue(true)); ctx_menu_.exec(event->globalPos()); decode_as_->setData(QVariant()); -- cgit v1.2.3