aboutsummaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorStig Bjørlykke <stig@bjorlykke.org>2020-07-02 10:20:14 +0200
committerStig Bjørlykke <stig@bjorlykke.org>2020-07-03 06:12:40 +0000
commita6d8a2c1181e50b3471ef4321e8ed501ab210fe5 (patch)
tree56c3597901b0a9ba33109173af454cf59b381c68 /ui
parent7bf8a87429ee61526132650e27763ed203d880ce (diff)
Qt: List all protocols in PacketList "Protocol Preferences"
Show all protocols which has preferences in the packet list context menu "Protocol Preferences". Change-Id: I72e2ed95db36cc6d817ca44db214782f075d55d6 Reviewed-on: https://code.wireshark.org/review/37666 Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org> Tested-by: Petri Dish Buildbot Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
Diffstat (limited to 'ui')
-rw-r--r--ui/qt/packet_list.cpp39
-rw-r--r--ui/qt/packet_list.h2
-rw-r--r--ui/qt/protocol_preferences_menu.cpp6
-rw-r--r--ui/qt/protocol_preferences_menu.h1
4 files changed, 32 insertions, 16 deletions
diff --git a/ui/qt/packet_list.cpp b/ui/qt/packet_list.cpp
index 78dedda7e3..4916010834 100644
--- a/ui/qt/packet_list.cpp
+++ b/ui/qt/packet_list.cpp
@@ -239,6 +239,8 @@ PacketList::PacketList(QWidget *parent) :
setUniformRowHeights(true);
setAccessibleName("Packet list");
+ proto_prefs_menus_.setTitle(tr("Protocol Preferences"));
+
packet_list_header_ = new PacketListHeader(header()->orientation(), cap_file_);
connect(packet_list_header_, &PacketListHeader::resetColumnWidth, this, &PacketList::setRecentColumnWidth);
connect(packet_list_header_, &PacketListHeader::updatePackets, this, &PacketList::updatePackets);
@@ -279,11 +281,6 @@ PacketList::PacketList(QWidget *parent) :
this, SLOT(sectionMoved(int,int,int)));
connect(verticalScrollBar(), SIGNAL(actionTriggered(int)), this, SLOT(vScrollBarActionTriggered(int)));
-
- connect(&proto_prefs_menu_, SIGNAL(showProtocolPreferences(QString)),
- this, SIGNAL(showProtocolPreferences(QString)));
- connect(&proto_prefs_menu_, SIGNAL(editProtocolPreference(preference*,pref_module*)),
- this, SIGNAL(editProtocolPreference(preference*,pref_module*)));
}
void PacketList::colorsChanged()
@@ -591,29 +588,41 @@ void PacketList::selectionChanged (const QItemSelection & selected, const QItemS
void PacketList::contextMenuEvent(QContextMenuEvent *event)
{
const char *module_name = NULL;
+
+ proto_prefs_menus_.clear();
+
if (cap_file_ && cap_file_->edt && cap_file_->edt->tree) {
- GPtrArray *finfo_array = proto_all_finfos(cap_file_->edt->tree);
+ GPtrArray *finfo_array = proto_all_finfos(cap_file_->edt->tree);
+ QList<QString> added_proto_prefs;
- for (guint i = finfo_array->len - 1; i > 0 ; i --) {
+ for (guint i = 0; i < finfo_array->len; i++) {
field_info *fi = (field_info *)g_ptr_array_index (finfo_array, i);
header_field_info *hfinfo = fi->hfinfo;
- if (!g_str_has_prefix(hfinfo->abbrev, "text") &&
- !g_str_has_prefix(hfinfo->abbrev, "_ws.expert") &&
- !g_str_has_prefix(hfinfo->abbrev, "_ws.lua") &&
- !g_str_has_prefix(hfinfo->abbrev, "_ws.malformed")) {
-
+ if (prefs_is_registered_protocol(hfinfo->abbrev)) {
if (hfinfo->parent == -1) {
module_name = hfinfo->abbrev;
} else {
module_name = proto_registrar_get_abbrev(hfinfo->parent);
}
- break;
+
+ if (added_proto_prefs.contains(module_name)) {
+ continue;
+ }
+
+ ProtocolPreferencesMenu *proto_prefs_menu = new ProtocolPreferencesMenu(hfinfo->name, module_name, &proto_prefs_menus_);
+
+ connect(proto_prefs_menu, SIGNAL(showProtocolPreferences(QString)),
+ this, SIGNAL(showProtocolPreferences(QString)));
+ connect(proto_prefs_menu, SIGNAL(editProtocolPreference(preference*,pref_module*)),
+ this, SIGNAL(editProtocolPreference(preference*,pref_module*)));
+
+ proto_prefs_menus_.addMenu(proto_prefs_menu);
+ added_proto_prefs << module_name;
}
}
g_ptr_array_free(finfo_array, TRUE);
}
- proto_prefs_menu_.setModule(module_name);
QModelIndex ctxIndex = indexAt(event->pos());
@@ -705,7 +714,7 @@ void PacketList::contextMenuEvent(QContextMenuEvent *event)
frameData->setParent(submenu);
ctx_menu->addSeparator();
- ctx_menu->addMenu(&proto_prefs_menu_);
+ ctx_menu->addMenu(&proto_prefs_menus_);
action = ctx_menu->addAction(tr("Decode As" UTF8_HORIZONTAL_ELLIPSIS));
action->setProperty("create_new", QVariant(true));
connect(action, &QAction::triggered, this, &PacketList::ctxDecodeAsDialog);
diff --git a/ui/qt/packet_list.h b/ui/qt/packet_list.h
index ff1873b915..c014e87236 100644
--- a/ui/qt/packet_list.h
+++ b/ui/qt/packet_list.h
@@ -114,7 +114,7 @@ private:
capture_file *cap_file_;
QMenu conv_menu_;
QMenu colorize_menu_;
- ProtocolPreferencesMenu proto_prefs_menu_;
+ QMenu proto_prefs_menus_;
int ctx_column_;
QByteArray column_state_;
OverlayScrollBar *overlay_sb_;
diff --git a/ui/qt/protocol_preferences_menu.cpp b/ui/qt/protocol_preferences_menu.cpp
index a9b76297d0..fc4fe41431 100644
--- a/ui/qt/protocol_preferences_menu.cpp
+++ b/ui/qt/protocol_preferences_menu.cpp
@@ -136,6 +136,12 @@ ProtocolPreferencesMenu::ProtocolPreferencesMenu()
setModule(NULL);
}
+ProtocolPreferencesMenu::ProtocolPreferencesMenu(const QString &title, const QString &module_name, QWidget *parent) :
+ QMenu(title, parent)
+{
+ setModule(module_name);
+}
+
void ProtocolPreferencesMenu::setModule(const QString module_name)
{
QAction *action;
diff --git a/ui/qt/protocol_preferences_menu.h b/ui/qt/protocol_preferences_menu.h
index 4dfcda12e6..f13412e580 100644
--- a/ui/qt/protocol_preferences_menu.h
+++ b/ui/qt/protocol_preferences_menu.h
@@ -22,6 +22,7 @@ class ProtocolPreferencesMenu : public QMenu
public:
ProtocolPreferencesMenu();
+ ProtocolPreferencesMenu(const QString &title, const QString &module_name, QWidget *parent = nullptr);
void setModule(const QString module_name);
void addMenuItem(struct preference *pref);