diff options
author | Gerald Combs <gerald@wireshark.org> | 2015-07-27 16:17:44 -0700 |
---|---|---|
committer | Gerald Combs <gerald@wireshark.org> | 2015-07-28 03:54:38 +0000 |
commit | 65a1f60e70184faf0238e4df2585af056be1e4c7 (patch) | |
tree | 5d071fb00afc44faf08c489ccf98d073033fb0ab /ui/qt/protocol_preferences_menu.cpp | |
parent | 01bc31cded7290433704e9ef98a90e338c3ea28b (diff) |
Add "Disable Protocol..." to the ProtoTree context menu.
Assume that "I don't want to see this" counts as a preference and add it
under the "Protocol Preferences" submenu.
Change-Id: I396e2476509db9df895826f8817b191893bcb14a
Reviewed-on: https://code.wireshark.org/review/9812
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Gerald Combs <gerald@wireshark.org>
Diffstat (limited to 'ui/qt/protocol_preferences_menu.cpp')
-rw-r--r-- | ui/qt/protocol_preferences_menu.cpp | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/ui/qt/protocol_preferences_menu.cpp b/ui/qt/protocol_preferences_menu.cpp index 81fd630a71..31fb882331 100644 --- a/ui/qt/protocol_preferences_menu.cpp +++ b/ui/qt/protocol_preferences_menu.cpp @@ -32,6 +32,7 @@ #include "protocol_preferences_menu.h" +#include "enabled_protocols_dialog.h" #include "qt_ui_utils.h" #include "uat_dialog.h" #include "wireshark_application.h" @@ -178,25 +179,32 @@ void ProtocolPreferencesMenu::setModule(const char *module_name) { QAction *action; int proto_id = -1; - protocol_t *protocol; + + if (module_name) { + proto_id = proto_get_id_by_filter_name(module_name); + } clear(); module_name_.clear(); module_ = NULL; - if (!module_name || - (proto_id = proto_get_id_by_filter_name(module_name)) < 0 || - !(protocol = find_protocol_by_id(proto_id))) { + protocol_ = find_protocol_by_id(proto_id); + const QString proto_name = proto_get_protocol_long_name(protocol_); + if (!module_name || proto_id < 0 || !protocol_) { action = addAction(tr("No protocol preferences available")); action->setDisabled(true); return; } + QAction *disable_action = new QAction(tr("Disable %1" UTF8_HORIZONTAL_ELLIPSIS).arg(proto_name), this); + connect(disable_action, SIGNAL(triggered(bool)), this, SLOT(disableProtocolTriggered())); + module_ = prefs_find_module(module_name); - const QString proto_name = proto_get_protocol_long_name(protocol); if (!module_ || !prefs_is_registered_protocol(module_name)) { action = addAction(tr("%1 has no preferences").arg(proto_name)); action->setDisabled(true); + addSeparator(); + addAction(disable_action); return; } @@ -205,10 +213,14 @@ void ProtocolPreferencesMenu::setModule(const char *module_name) action = addAction(tr("Open %1 preferences" UTF8_HORIZONTAL_ELLIPSIS).arg(proto_name)); action->setData(QString(module_name)); connect(action, SIGNAL(triggered(bool)), this, SLOT(modulePreferencesTriggered())); - addSeparator(); prefs_pref_foreach(module_, add_prefs_menu_item, this); + + if (!actions().last()->isSeparator()) { + addSeparator(); + } + addAction(disable_action); } void ProtocolPreferencesMenu::addMenuItem(preference *pref) @@ -269,6 +281,14 @@ void ProtocolPreferencesMenu::addMenuItem(preference *pref) } } +void ProtocolPreferencesMenu::disableProtocolTriggered() +{ + EnabledProtocolsDialog enable_proto_dialog(this); + enable_proto_dialog.selectProtocol(protocol_); + hide(); + enable_proto_dialog.exec(); +} + void ProtocolPreferencesMenu::modulePreferencesTriggered() { if (!module_name_.isEmpty()) { |