diff options
author | Roland Knall <rknall@gmail.com> | 2019-08-26 16:30:05 +0200 |
---|---|---|
committer | Roland Knall <rknall@gmail.com> | 2019-08-26 19:57:24 +0000 |
commit | c9361120f0a7544d0fc95a24d0e51aaaaf09c89a (patch) | |
tree | 96a385bbdb13848aa96798ef21bedc94bfe6e8bb | |
parent | 3870e6c0365d90f53c89a3fb5537f1b9a4d6218e (diff) |
Qt: Remove unnecessary code for context menus
This code is no longer required, as context menus should
be bound to local events.
As for "Reloading LUA plugins" - the keyboard shortcut would
be able to trigger while the menu is open, except Qt explicitely
prevents that
Change-Id: Id18a3a17d62bae1ff547a6ef96772e12a2535219
Reviewed-on: https://code.wireshark.org/review/34371
Petri-Dish: Roland Knall <rknall@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Roland Knall <rknall@gmail.com>
-rw-r--r-- | ui/qt/main_window_slots.cpp | 1 | ||||
-rw-r--r-- | ui/qt/packet_list.cpp | 54 | ||||
-rw-r--r-- | ui/qt/packet_list.h | 1 | ||||
-rw-r--r-- | ui/qt/proto_tree.cpp | 69 | ||||
-rw-r--r-- | ui/qt/proto_tree.h | 2 |
5 files changed, 59 insertions, 68 deletions
diff --git a/ui/qt/main_window_slots.cpp b/ui/qt/main_window_slots.cpp index 21a6d5477e..aab4c23384 100644 --- a/ui/qt/main_window_slots.cpp +++ b/ui/qt/main_window_slots.cpp @@ -1470,7 +1470,6 @@ void MainWindow::reloadLuaPlugins() closePacketDialogs(); // Preferences may have been deleted so close all widgets using prefs - proto_tree_->closeContextMenu(); main_ui_->preferenceEditorFrame->animatedHide(); wsApp->readConfigurationFiles(true); diff --git a/ui/qt/packet_list.cpp b/ui/qt/packet_list.cpp index 3e52a027a9..ee4ba6d47f 100644 --- a/ui/qt/packet_list.cpp +++ b/ui/qt/packet_list.cpp @@ -486,23 +486,23 @@ void PacketList::contextMenuEvent(QContextMenuEvent *event) FrameInformation * frameData = new FrameInformation(new CaptureFile(this, cap_file_), packet_list_model_->getRowFdata(ctxIndex.row())); - ctx_menu_.clear(); + QMenu ctx_menu(this); // XXX We might want to reimplement setParent() and fill in the context // menu there. - ctx_menu_.addAction(window()->findChild<QAction *>("actionEditMarkPacket")); - ctx_menu_.addAction(window()->findChild<QAction *>("actionEditIgnorePacket")); - ctx_menu_.addAction(window()->findChild<QAction *>("actionEditSetTimeReference")); - ctx_menu_.addAction(window()->findChild<QAction *>("actionEditTimeShift")); - ctx_menu_.addAction(window()->findChild<QAction *>("actionEditPacketComment")); + ctx_menu.addAction(window()->findChild<QAction *>("actionEditMarkPacket")); + ctx_menu.addAction(window()->findChild<QAction *>("actionEditIgnorePacket")); + ctx_menu.addAction(window()->findChild<QAction *>("actionEditSetTimeReference")); + ctx_menu.addAction(window()->findChild<QAction *>("actionEditTimeShift")); + ctx_menu.addAction(window()->findChild<QAction *>("actionEditPacketComment")); - ctx_menu_.addSeparator(); + ctx_menu.addSeparator(); - ctx_menu_.addAction(window()->findChild<QAction *>("actionViewEditResolvedName")); - ctx_menu_.addSeparator(); + ctx_menu.addAction(window()->findChild<QAction *>("actionViewEditResolvedName")); + ctx_menu.addSeparator(); QMenu *main_menu_item = window()->findChild<QMenu *>("menuApplyAsFilter"); - QMenu *submenu = new QMenu(main_menu_item->title(), &ctx_menu_); - ctx_menu_.addMenu(submenu); + QMenu *submenu = new QMenu(main_menu_item->title(), &ctx_menu); + ctx_menu.addMenu(submenu); submenu->addAction(window()->findChild<QAction *>("actionAnalyzeAAFSelected")); submenu->addAction(window()->findChild<QAction *>("actionAnalyzeAAFNotSelected")); submenu->addAction(window()->findChild<QAction *>("actionAnalyzeAAFAndSelected")); @@ -511,8 +511,8 @@ void PacketList::contextMenuEvent(QContextMenuEvent *event) submenu->addAction(window()->findChild<QAction *>("actionAnalyzeAAFOrNotSelected")); main_menu_item = window()->findChild<QMenu *>("menuPrepareAFilter"); - submenu = new QMenu(main_menu_item->title(), &ctx_menu_); - ctx_menu_.addMenu(submenu); + submenu = new QMenu(main_menu_item->title(), &ctx_menu); + ctx_menu.addMenu(submenu); submenu->addAction(window()->findChild<QAction *>("actionAnalyzePAFSelected")); submenu->addAction(window()->findChild<QAction *>("actionAnalyzePAFNotSelected")); submenu->addAction(window()->findChild<QAction *>("actionAnalyzePAFAndSelected")); @@ -524,34 +524,34 @@ void PacketList::contextMenuEvent(QContextMenuEvent *event) main_menu_item = window()->findChild<QMenu *>(conv_menu_name); conv_menu_.setTitle(main_menu_item->title()); conv_menu_.setObjectName(conv_menu_name); - ctx_menu_.addMenu(&conv_menu_); + ctx_menu.addMenu(&conv_menu_); const char *colorize_menu_name = "menuColorizeConversation"; main_menu_item = window()->findChild<QMenu *>(colorize_menu_name); colorize_menu_.setTitle(main_menu_item->title()); colorize_menu_.setObjectName(colorize_menu_name); - ctx_menu_.addMenu(&colorize_menu_); + ctx_menu.addMenu(&colorize_menu_); main_menu_item = window()->findChild<QMenu *>("menuSCTP"); - submenu = new QMenu(main_menu_item->title(), &ctx_menu_); - ctx_menu_.addMenu(submenu); + submenu = new QMenu(main_menu_item->title(), &ctx_menu); + ctx_menu.addMenu(submenu); submenu->addAction(window()->findChild<QAction *>("actionSCTPAnalyseThisAssociation")); submenu->addAction(window()->findChild<QAction *>("actionSCTPShowAllAssociations")); submenu->addAction(window()->findChild<QAction *>("actionSCTPFilterThisAssociation")); main_menu_item = window()->findChild<QMenu *>("menuFollow"); - submenu = new QMenu(main_menu_item->title(), &ctx_menu_); - ctx_menu_.addMenu(submenu); + submenu = new QMenu(main_menu_item->title(), &ctx_menu); + ctx_menu.addMenu(submenu); submenu->addAction(window()->findChild<QAction *>("actionAnalyzeFollowTCPStream")); submenu->addAction(window()->findChild<QAction *>("actionAnalyzeFollowUDPStream")); submenu->addAction(window()->findChild<QAction *>("actionAnalyzeFollowTLSStream")); submenu->addAction(window()->findChild<QAction *>("actionAnalyzeFollowHTTPStream")); - ctx_menu_.addSeparator(); + ctx_menu.addSeparator(); main_menu_item = window()->findChild<QMenu *>("menuEditCopy"); - submenu = new QMenu(main_menu_item->title(), &ctx_menu_); - ctx_menu_.addMenu(submenu); + submenu = new QMenu(main_menu_item->title(), &ctx_menu); + ctx_menu.addMenu(submenu); QAction * action = submenu->addAction(tr("Summary as Text")); action->setData(copy_summary_text_); @@ -572,13 +572,13 @@ void PacketList::contextMenuEvent(QContextMenuEvent *event) copyEntries->setParent(submenu); frameData->setParent(submenu); - ctx_menu_.addSeparator(); - ctx_menu_.addMenu(&proto_prefs_menu_); + ctx_menu.addSeparator(); + ctx_menu.addMenu(&proto_prefs_menu_); decode_as_ = window()->findChild<QAction *>("actionAnalyzeDecodeAs"); - ctx_menu_.addAction(decode_as_); + ctx_menu.addAction(decode_as_); // "Print" not ported intentionally action = window()->findChild<QAction *>("actionViewShowPacketInNewWindow"); - ctx_menu_.addAction(action); + ctx_menu.addAction(action); decode_as_->setData(QVariant::fromValue(true)); @@ -588,7 +588,7 @@ void PacketList::contextMenuEvent(QContextMenuEvent *event) else emit frameSelected(-1); - ctx_menu_.exec(event->globalPos()); + ctx_menu.exec(event->globalPos()); decode_as_->setData(QVariant()); } diff --git a/ui/qt/packet_list.h b/ui/qt/packet_list.h index 65694286e6..e8be4b5b6a 100644 --- a/ui/qt/packet_list.h +++ b/ui/qt/packet_list.h @@ -88,7 +88,6 @@ private: PacketListHeader * packet_list_header_; ProtoTree *proto_tree_; capture_file *cap_file_; - QMenu ctx_menu_; QMenu conv_menu_; QMenu colorize_menu_; ProtocolPreferencesMenu proto_prefs_menu_; diff --git a/ui/qt/proto_tree.cpp b/ui/qt/proto_tree.cpp index 80c4607d68..81dbd45bfd 100644 --- a/ui/qt/proto_tree.cpp +++ b/ui/qt/proto_tree.cpp @@ -101,11 +101,6 @@ void ProtoTree::clear() { updateContentWidth(); } -void ProtoTree::closeContextMenu() -{ - ctx_menu_.close(); -} - void ProtoTree::protoTreeContextMenu(QContextMenuEvent * event) { QMenu ctxMenu(this); @@ -306,20 +301,20 @@ void ProtoTree::contextMenuEvent(QContextMenuEvent *event) return; } - ctx_menu_.clear(); + QMenu ctx_menu(this); QMenu *main_menu_item, *submenu; QAction *action; - ctx_menu_.addAction(window()->findChild<QAction *>("actionViewExpandSubtrees")); - ctx_menu_.addAction(window()->findChild<QAction *>("actionViewCollapseSubtrees")); - ctx_menu_.addAction(window()->findChild<QAction *>("actionViewExpandAll")); - ctx_menu_.addAction(window()->findChild<QAction *>("actionViewCollapseAll")); - ctx_menu_.addSeparator(); + ctx_menu.addAction(window()->findChild<QAction *>("actionViewExpandSubtrees")); + ctx_menu.addAction(window()->findChild<QAction *>("actionViewCollapseSubtrees")); + ctx_menu.addAction(window()->findChild<QAction *>("actionViewExpandAll")); + ctx_menu.addAction(window()->findChild<QAction *>("actionViewCollapseAll")); + ctx_menu.addSeparator(); action = window()->findChild<QAction *>("actionAnalyzeCreateAColumn"); - ctx_menu_.addAction(action); - ctx_menu_.addSeparator(); + ctx_menu.addAction(action); + ctx_menu.addSeparator(); QModelIndex index = indexAt(event->pos()); FieldInformation finfo(proto_tree_model_->protoNodeFromIndex(index).protoNode()); @@ -327,14 +322,14 @@ void ProtoTree::contextMenuEvent(QContextMenuEvent *event) epan_dissect_t *edt = cap_file_ ? cap_file_->edt : edt_; char * selectedfilter = proto_construct_match_selected_string(finfo.fieldInfo(), edt); bool can_match_selected = proto_can_match_selected(finfo.fieldInfo(), edt); - main_menu_item = new QMenu(tr("Apply as Filter"), &ctx_menu_); - QActionGroup * group = FilterAction::createFilterGroup(selectedfilter, false, can_match_selected, &ctx_menu_); + main_menu_item = new QMenu(tr("Apply as Filter"), &ctx_menu); + QActionGroup * group = FilterAction::createFilterGroup(selectedfilter, false, can_match_selected, &ctx_menu); main_menu_item->addActions(group->actions()); - ctx_menu_.addMenu(main_menu_item); - main_menu_item = new QMenu(tr("Prepare as Filter"), &ctx_menu_); - group = FilterAction::createFilterGroup(selectedfilter, true, can_match_selected, &ctx_menu_); + ctx_menu.addMenu(main_menu_item); + main_menu_item = new QMenu(tr("Prepare as Filter"), &ctx_menu); + group = FilterAction::createFilterGroup(selectedfilter, true, can_match_selected, &ctx_menu); main_menu_item->addActions(group->actions()); - ctx_menu_.addMenu(main_menu_item); + ctx_menu.addMenu(main_menu_item); if ( selectedfilter ) wmem_free(Q_NULLPTR, selectedfilter); @@ -345,23 +340,23 @@ void ProtoTree::contextMenuEvent(QContextMenuEvent *event) conv_menu_.addAction(action); } - ctx_menu_.addMenu(&conv_menu_); + ctx_menu.addMenu(&conv_menu_); colorize_menu_.setTitle(tr("Colorize with Filter")); - ctx_menu_.addMenu(&colorize_menu_); + ctx_menu.addMenu(&colorize_menu_); main_menu_item = window()->findChild<QMenu *>("menuFollow"); - submenu = new QMenu(main_menu_item->title(), &ctx_menu_); - ctx_menu_.addMenu(submenu); + submenu = new QMenu(main_menu_item->title(), &ctx_menu); + ctx_menu.addMenu(submenu); submenu->addAction(window()->findChild<QAction *>("actionAnalyzeFollowTCPStream")); submenu->addAction(window()->findChild<QAction *>("actionAnalyzeFollowUDPStream")); submenu->addAction(window()->findChild<QAction *>("actionAnalyzeFollowTLSStream")); submenu->addAction(window()->findChild<QAction *>("actionAnalyzeFollowHTTPStream")); - ctx_menu_.addSeparator(); + ctx_menu.addSeparator(); main_menu_item = window()->findChild<QMenu *>("menuEditCopy"); - submenu = new QMenu(main_menu_item->title(), &ctx_menu_); - ctx_menu_.addMenu(submenu); + submenu = new QMenu(main_menu_item->title(), &ctx_menu); + ctx_menu.addMenu(submenu); submenu->addAction(window()->findChild<QAction *>("actionCopyAllVisibleItems")); submenu->addAction(window()->findChild<QAction *>("actionCopyAllVisibleSelectedTreeItems")); submenu->addAction(window()->findChild<QAction *>("actionEditCopyDescription")); @@ -376,23 +371,23 @@ void ProtoTree::contextMenuEvent(QContextMenuEvent *event) submenu->addActions(copyEntries->actions()); action = window()->findChild<QAction *>("actionAnalyzeShowPacketBytes"); - ctx_menu_.addAction(action); + ctx_menu.addAction(action); action = window()->findChild<QAction *>("actionFileExportPacketBytes"); - ctx_menu_.addAction(action); + ctx_menu.addAction(action); - ctx_menu_.addSeparator(); + ctx_menu.addSeparator(); action = window()->findChild<QAction *>("actionContextWikiProtocolPage"); - ctx_menu_.addAction(action); + ctx_menu.addAction(action); action = window()->findChild<QAction *>("actionContextFilterFieldReference"); - ctx_menu_.addAction(action); - ctx_menu_.addMenu(&proto_prefs_menu_); - ctx_menu_.addSeparator(); + ctx_menu.addAction(action); + ctx_menu.addMenu(&proto_prefs_menu_); + ctx_menu.addSeparator(); decode_as_ = window()->findChild<QAction *>("actionAnalyzeDecodeAs"); - ctx_menu_.addAction(decode_as_); + ctx_menu.addAction(decode_as_); - ctx_menu_.addAction(window()->findChild<QAction *>("actionGoGoToLinkedPacket")); - ctx_menu_.addAction(window()->findChild<QAction *>("actionContextShowLinkedPacketInNewWindow")); + ctx_menu.addAction(window()->findChild<QAction *>("actionGoGoToLinkedPacket")); + ctx_menu.addAction(window()->findChild<QAction *>("actionContextShowLinkedPacketInNewWindow")); // The "text only" header field will not give preferences for the selected protocol. // Use parent in this case. @@ -405,7 +400,7 @@ void ProtoTree::contextMenuEvent(QContextMenuEvent *event) decode_as_->setData(QVariant::fromValue(true)); - ctx_menu_.exec(event->globalPos()); + ctx_menu.exec(event->globalPos()); decode_as_->setData(QVariant()); } diff --git a/ui/qt/proto_tree.h b/ui/qt/proto_tree.h index 4fee161cc8..e4794796d8 100644 --- a/ui/qt/proto_tree.h +++ b/ui/qt/proto_tree.h @@ -36,7 +36,6 @@ public: void autoScrollTo(const QModelIndex &index); void goToHfid(int hfid); void clear(); - void closeContextMenu(); void restoreSelectedField(); QString toString(const QModelIndex &start_idx = QModelIndex()) const; @@ -59,7 +58,6 @@ protected: private: ProtoTreeModel *proto_tree_model_; - QMenu ctx_menu_; QMenu conv_menu_; QMenu colorize_menu_; ProtocolPreferencesMenu proto_prefs_menu_; |