From de387814bb060678f7c85c0632058c574838d0b7 Mon Sep 17 00:00:00 2001 From: Gerald Combs Date: Thu, 22 Sep 2022 15:15:48 -0700 Subject: [PATCH] Qt: Manually connect our "File" menu actions. --- ui/logray/logray_main_window.cpp | 1 + ui/logray/logray_main_window.h | 25 +-- ui/logray/logray_main_window_slots.cpp | 181 ++++++++++------------ ui/qt/wireshark_main_window.cpp | 1 + ui/qt/wireshark_main_window.h | 29 +--- ui/qt/wireshark_main_window_slots.cpp | 201 ++++++++++++------------- 6 files changed, 191 insertions(+), 247 deletions(-) diff --git a/ui/logray/logray_main_window.cpp b/ui/logray/logray_main_window.cpp index 3a6f29219c..59e3cbbedf 100644 --- a/ui/logray/logray_main_window.cpp +++ b/ui/logray/logray_main_window.cpp @@ -598,6 +598,7 @@ main_ui_->goToLineEdit->setValidator(goToLineQiv); connect(mainApp, SIGNAL(zoomMonospaceFont(QFont)), proto_tree_, SLOT(setMonospaceFont(QFont))); + connectFileMenuActions(); connectEditMenuActions(); connect(main_ui_->actionGoNextPacket, SIGNAL(triggered()), diff --git a/ui/logray/logray_main_window.h b/ui/logray/logray_main_window.h index 0ad1482242..46391975fb 100644 --- a/ui/logray/logray_main_window.h +++ b/ui/logray/logray_main_window.h @@ -388,27 +388,10 @@ private slots: // We might want move these to main_window_actions.cpp similar to // gtk/main_menubar.c - void on_actionFileOpen_triggered(); - void on_actionFileMerge_triggered(); - void on_actionFileImportFromHexDump_triggered(); - void on_actionFileClose_triggered(); - void on_actionFileSave_triggered(); - void on_actionFileSaveAs_triggered(); - void on_actionFileSetListFiles_triggered(); - void on_actionFileSetNextFile_triggered(); - void on_actionFileSetPreviousFile_triggered(); - void on_actionFileExportPackets_triggered(); - void on_actionFileExportAsPlainText_triggered(); - // We're dropping PostScript exports - void on_actionFileExportAsCSV_triggered(); - void on_actionFileExportAsCArrays_triggered(); - void on_actionFileExportAsPSML_triggered(); - void on_actionFileExportAsPDML_triggered(); - void on_actionFileExportAsJSON_triggered(); - void on_actionFileExportPacketBytes_triggered(); - void on_actionFilePrint_triggered(); - - void on_actionFileExportPDU_triggered(); + void connectFileMenuActions(); + void exportPacketBytes(); + void exportPDU(); + void printFile(); void connectEditMenuActions(); void copySelectedItems(LograyMainWindow::CopySelected selection_type); diff --git a/ui/logray/logray_main_window_slots.cpp b/ui/logray/logray_main_window_slots.cpp index c9366a27ab..17c06d3b15 100644 --- a/ui/logray/logray_main_window_slots.cpp +++ b/ui/logray/logray_main_window_slots.cpp @@ -1663,98 +1663,83 @@ void LograyMainWindow::softwareUpdateRequested() { // File Menu -void LograyMainWindow::on_actionFileOpen_triggered() +void LograyMainWindow::connectFileMenuActions() { - openCaptureFile(); + connect(main_ui_->actionFileOpen, &QAction::triggered, this, + [this]() { openCaptureFile(); }); + + connect(main_ui_->actionFileMerge, &QAction::triggered, this, + [this]() { mergeCaptureFile(); }); + + connect(main_ui_->actionFileImportFromHexDump, &QAction::triggered, this, + [this]() { importCaptureFile(); }); + + connect(main_ui_->actionFileClose, &QAction::triggered, this, [this]() { + QString before_what(tr(" before closing the file")); + if (testCaptureFileClose(before_what)) { + showWelcome(); + } + }); + + connect(main_ui_->actionFileSave, &QAction::triggered, this, + [this]() { saveCaptureFile(capture_file_.capFile(), false); }); + + connect(main_ui_->actionFileSaveAs, &QAction::triggered, this, + [this]() { saveAsCaptureFile(capture_file_.capFile()); }); + + connect(main_ui_->actionFileSetListFiles, &QAction::triggered, this, + [this]() { file_set_dialog_->show(); }); + + connect(main_ui_->actionFileSetNextFile, &QAction::triggered, this, [this]() { + fileset_entry *entry = fileset_get_next(); + + if (entry) { + QString new_cf_path = entry->fullname; + openCaptureFile(new_cf_path); + } + }); + + connect(main_ui_->actionFileSetPreviousFile, &QAction::triggered, this, [this]() { + fileset_entry *entry = fileset_get_previous(); + + if (entry) { + QString new_cf_path = entry->fullname; + openCaptureFile(new_cf_path); + } + }); + + connect(main_ui_->actionFileExportPackets, &QAction::triggered, this, + [this]() { exportSelectedPackets(); }); + + connect(main_ui_->actionFileExportAsPlainText, &QAction::triggered, this, + [this]() { exportDissections(export_type_text); }); + + connect(main_ui_->actionFileExportAsCSV, &QAction::triggered, this, + [this]() { exportDissections(export_type_csv); }); + + connect(main_ui_->actionFileExportAsCArrays, &QAction::triggered, this, + [this]() { exportDissections(export_type_carrays); }); + + connect(main_ui_->actionFileExportAsPSML, &QAction::triggered, this, + [this]() { exportDissections(export_type_psml); }); + + connect(main_ui_->actionFileExportAsPDML, &QAction::triggered, this, + [this]() { exportDissections(export_type_pdml); }); + + connect(main_ui_->actionFileExportAsJSON, &QAction::triggered, this, + [this]() { exportDissections(export_type_json); }); + + connect(main_ui_->actionFileExportPacketBytes, &QAction::triggered, this, + [this]() { exportPacketBytes(); }); + + connect(main_ui_->actionFileExportPDU, &QAction::triggered, this, + [this]() { exportPDU(); }); + + connect(main_ui_->actionFilePrint, &QAction::triggered, this, + [this]() { printFile(); }); } -void LograyMainWindow::on_actionFileMerge_triggered() -{ - mergeCaptureFile(); -} - -void LograyMainWindow::on_actionFileImportFromHexDump_triggered() -{ - importCaptureFile(); -} - -void LograyMainWindow::on_actionFileClose_triggered() { - QString before_what(tr(" before closing the file")); - if (testCaptureFileClose(before_what)) - showWelcome(); -} - -void LograyMainWindow::on_actionFileSave_triggered() -{ - saveCaptureFile(capture_file_.capFile(), false); -} - -void LograyMainWindow::on_actionFileSaveAs_triggered() -{ - saveAsCaptureFile(capture_file_.capFile()); -} - -void LograyMainWindow::on_actionFileSetListFiles_triggered() -{ - file_set_dialog_->show(); -} - -void LograyMainWindow::on_actionFileSetNextFile_triggered() -{ - fileset_entry *entry = fileset_get_next(); - - if (entry) { - QString new_cf_path = entry->fullname; - openCaptureFile(new_cf_path); - } -} - -void LograyMainWindow::on_actionFileSetPreviousFile_triggered() -{ - fileset_entry *entry = fileset_get_previous(); - - if (entry) { - QString new_cf_path = entry->fullname; - openCaptureFile(new_cf_path); - } -} - -void LograyMainWindow::on_actionFileExportPackets_triggered() -{ - exportSelectedPackets(); -} - -void LograyMainWindow::on_actionFileExportAsPlainText_triggered() -{ - exportDissections(export_type_text); -} - -void LograyMainWindow::on_actionFileExportAsCSV_triggered() -{ - exportDissections(export_type_csv); -} - -void LograyMainWindow::on_actionFileExportAsCArrays_triggered() -{ - exportDissections(export_type_carrays); -} - -void LograyMainWindow::on_actionFileExportAsPSML_triggered() -{ - exportDissections(export_type_psml); -} - -void LograyMainWindow::on_actionFileExportAsPDML_triggered() -{ - exportDissections(export_type_pdml); -} - -void LograyMainWindow::on_actionFileExportAsJSON_triggered() -{ - exportDissections(export_type_json); -} - -void LograyMainWindow::on_actionFileExportPacketBytes_triggered() +void LograyMainWindow::exportPacketBytes() { QString file_name; @@ -1778,14 +1763,7 @@ void LograyMainWindow::on_actionFileExportPacketBytes_triggered() } } -void LograyMainWindow::on_actionAnalyzeShowPacketBytes_triggered() -{ - ShowPacketBytesDialog *spbd = new ShowPacketBytesDialog(*this, capture_file_); - spbd->addCodecs(text_codec_map_); - spbd->show(); -} - -void LograyMainWindow::on_actionFileExportPDU_triggered() +void LograyMainWindow::exportPDU() { ExportPDUDialog *exportpdu_dialog = new ExportPDUDialog(this); @@ -1802,7 +1780,7 @@ void LograyMainWindow::on_actionFileExportPDU_triggered() exportpdu_dialog->activateWindow(); } -void LograyMainWindow::on_actionFilePrint_triggered() +void LograyMainWindow::printFile() { capture_file *cf = capture_file_.capFile(); g_return_if_fail(cf); @@ -2783,6 +2761,13 @@ void LograyMainWindow::statCommandExpertInfo(const char *, void *) expert_dialog->show(); } +void LograyMainWindow::on_actionAnalyzeShowPacketBytes_triggered() +{ + ShowPacketBytesDialog *spbd = new ShowPacketBytesDialog(*this, capture_file_); + spbd->addCodecs(text_codec_map_); + spbd->show(); +} + void LograyMainWindow::on_actionAnalyzeExpertInfo_triggered() { statCommandExpertInfo(NULL, NULL); diff --git a/ui/qt/wireshark_main_window.cpp b/ui/qt/wireshark_main_window.cpp index fe27929c50..9065a0e5fb 100644 --- a/ui/qt/wireshark_main_window.cpp +++ b/ui/qt/wireshark_main_window.cpp @@ -626,6 +626,7 @@ main_ui_->goToLineEdit->setValidator(goToLineQiv); connect(mainApp, SIGNAL(zoomMonospaceFont(QFont)), proto_tree_, SLOT(setMonospaceFont(QFont))); + connectFileMenuActions(); connectEditMenuActions(); connect(main_ui_->actionAnalyzeFollowTCPStream, &QAction::triggered, this, diff --git a/ui/qt/wireshark_main_window.h b/ui/qt/wireshark_main_window.h index 589c3d8638..c57869fc30 100644 --- a/ui/qt/wireshark_main_window.h +++ b/ui/qt/wireshark_main_window.h @@ -411,29 +411,12 @@ private slots: // We might want move these to main_window_actions.cpp similar to // gtk/main_menubar.c - void on_actionFileOpen_triggered(); - void on_actionFileMerge_triggered(); - void on_actionFileImportFromHexDump_triggered(); - void on_actionFileClose_triggered(); - void on_actionFileSave_triggered(); - void on_actionFileSaveAs_triggered(); - void on_actionFileSetListFiles_triggered(); - void on_actionFileSetNextFile_triggered(); - void on_actionFileSetPreviousFile_triggered(); - void on_actionFileExportPackets_triggered(); - void on_actionFileExportAsPlainText_triggered(); - // We're dropping PostScript exports - void on_actionFileExportAsCSV_triggered(); - void on_actionFileExportAsCArrays_triggered(); - void on_actionFileExportAsPSML_triggered(); - void on_actionFileExportAsPDML_triggered(); - void on_actionFileExportAsJSON_triggered(); - void on_actionFileExportPacketBytes_triggered(); - void on_actionFilePrint_triggered(); - - void on_actionFileExportPDU_triggered(); - void on_actionFileStripHeaders_triggered(); - void on_actionFileExportTLSSessionKeys_triggered(); + void connectFileMenuActions(); + void exportPacketBytes(); + void exportPDU(); + void stripPacketHeaders(); + void exportTLSSessionKeys(); + void printFile(); void connectEditMenuActions(); void copySelectedItems(WiresharkMainWindow::CopySelected selection_type); diff --git a/ui/qt/wireshark_main_window_slots.cpp b/ui/qt/wireshark_main_window_slots.cpp index e562101cbe..324e465fb1 100644 --- a/ui/qt/wireshark_main_window_slots.cpp +++ b/ui/qt/wireshark_main_window_slots.cpp @@ -1770,98 +1770,89 @@ void WiresharkMainWindow::softwareUpdateRequested() { // File Menu -void WiresharkMainWindow::on_actionFileOpen_triggered() +void WiresharkMainWindow::connectFileMenuActions() { - openCaptureFile(); + connect(main_ui_->actionFileOpen, &QAction::triggered, this, + [this]() { openCaptureFile(); }); + + connect(main_ui_->actionFileMerge, &QAction::triggered, this, + [this]() { mergeCaptureFile(); }); + + connect(main_ui_->actionFileImportFromHexDump, &QAction::triggered, this, + [this]() { importCaptureFile(); }); + + connect(main_ui_->actionFileClose, &QAction::triggered, this, [this]() { + QString before_what(tr(" before closing the file")); + if (testCaptureFileClose(before_what)) { + showWelcome(); + } + }); + + connect(main_ui_->actionFileSave, &QAction::triggered, this, + [this]() { saveCaptureFile(capture_file_.capFile(), false); }); + + connect(main_ui_->actionFileSaveAs, &QAction::triggered, this, + [this]() { saveAsCaptureFile(capture_file_.capFile()); }); + + connect(main_ui_->actionFileSetListFiles, &QAction::triggered, this, + [this]() { file_set_dialog_->show(); }); + + connect(main_ui_->actionFileSetNextFile, &QAction::triggered, this, [this]() { + fileset_entry *entry = fileset_get_next(); + + if (entry) { + QString new_cf_path = entry->fullname; + openCaptureFile(new_cf_path); + } + }); + + connect(main_ui_->actionFileSetPreviousFile, &QAction::triggered, this, [this]() { + fileset_entry *entry = fileset_get_previous(); + + if (entry) { + QString new_cf_path = entry->fullname; + openCaptureFile(new_cf_path); + } + }); + + connect(main_ui_->actionFileExportPackets, &QAction::triggered, this, + [this]() { exportSelectedPackets(); }); + + connect(main_ui_->actionFileExportAsPlainText, &QAction::triggered, this, + [this]() { exportDissections(export_type_text); }); + + connect(main_ui_->actionFileExportAsCSV, &QAction::triggered, this, + [this]() { exportDissections(export_type_csv); }); + + connect(main_ui_->actionFileExportAsCArrays, &QAction::triggered, this, + [this]() { exportDissections(export_type_carrays); }); + + connect(main_ui_->actionFileExportAsPSML, &QAction::triggered, this, + [this]() { exportDissections(export_type_psml); }); + + connect(main_ui_->actionFileExportAsPDML, &QAction::triggered, this, + [this]() { exportDissections(export_type_pdml); }); + + connect(main_ui_->actionFileExportAsJSON, &QAction::triggered, this, + [this]() { exportDissections(export_type_json); }); + + connect(main_ui_->actionFileExportPacketBytes, &QAction::triggered, this, + [this]() { exportPacketBytes(); }); + + connect(main_ui_->actionFileExportPDU, &QAction::triggered, this, + [this]() { exportPDU(); }); + + connect(main_ui_->actionFileStripHeaders, &QAction::triggered, this, + [this]() { stripPacketHeaders(); }); + + connect(main_ui_->actionFileExportTLSSessionKeys, &QAction::triggered, this, + [this]() { exportTLSSessionKeys(); }); + + connect(main_ui_->actionFilePrint, &QAction::triggered, this, + [this]() { printFile(); }); } -void WiresharkMainWindow::on_actionFileMerge_triggered() -{ - mergeCaptureFile(); -} - -void WiresharkMainWindow::on_actionFileImportFromHexDump_triggered() -{ - importCaptureFile(); -} - -void WiresharkMainWindow::on_actionFileClose_triggered() { - QString before_what(tr(" before closing the file")); - if (testCaptureFileClose(before_what)) - showWelcome(); -} - -void WiresharkMainWindow::on_actionFileSave_triggered() -{ - saveCaptureFile(capture_file_.capFile(), false); -} - -void WiresharkMainWindow::on_actionFileSaveAs_triggered() -{ - saveAsCaptureFile(capture_file_.capFile()); -} - -void WiresharkMainWindow::on_actionFileSetListFiles_triggered() -{ - file_set_dialog_->show(); -} - -void WiresharkMainWindow::on_actionFileSetNextFile_triggered() -{ - fileset_entry *entry = fileset_get_next(); - - if (entry) { - QString new_cf_path = entry->fullname; - openCaptureFile(new_cf_path); - } -} - -void WiresharkMainWindow::on_actionFileSetPreviousFile_triggered() -{ - fileset_entry *entry = fileset_get_previous(); - - if (entry) { - QString new_cf_path = entry->fullname; - openCaptureFile(new_cf_path); - } -} - -void WiresharkMainWindow::on_actionFileExportPackets_triggered() -{ - exportSelectedPackets(); -} - -void WiresharkMainWindow::on_actionFileExportAsPlainText_triggered() -{ - exportDissections(export_type_text); -} - -void WiresharkMainWindow::on_actionFileExportAsCSV_triggered() -{ - exportDissections(export_type_csv); -} - -void WiresharkMainWindow::on_actionFileExportAsCArrays_triggered() -{ - exportDissections(export_type_carrays); -} - -void WiresharkMainWindow::on_actionFileExportAsPSML_triggered() -{ - exportDissections(export_type_psml); -} - -void WiresharkMainWindow::on_actionFileExportAsPDML_triggered() -{ - exportDissections(export_type_pdml); -} - -void WiresharkMainWindow::on_actionFileExportAsJSON_triggered() -{ - exportDissections(export_type_json); -} - -void WiresharkMainWindow::on_actionFileExportPacketBytes_triggered() +void WiresharkMainWindow::exportPacketBytes() { QString file_name; @@ -1885,14 +1876,7 @@ void WiresharkMainWindow::on_actionFileExportPacketBytes_triggered() } } -void WiresharkMainWindow::on_actionAnalyzeShowPacketBytes_triggered() -{ - ShowPacketBytesDialog *spbd = new ShowPacketBytesDialog(*this, capture_file_); - spbd->addCodecs(text_codec_map_); - spbd->show(); -} - -void WiresharkMainWindow::on_actionFileExportPDU_triggered() +void WiresharkMainWindow::exportPDU() { ExportPDUDialog *exportpdu_dialog = new ExportPDUDialog(this); @@ -1909,7 +1893,7 @@ void WiresharkMainWindow::on_actionFileExportPDU_triggered() exportpdu_dialog->activateWindow(); } -void WiresharkMainWindow::on_actionFileStripHeaders_triggered() +void WiresharkMainWindow::stripPacketHeaders() { StripHeadersDialog *stripheaders_dialog = new StripHeadersDialog(this); @@ -1927,7 +1911,7 @@ void WiresharkMainWindow::on_actionFileStripHeaders_triggered() } -void WiresharkMainWindow::on_actionFileExportTLSSessionKeys_triggered() +void WiresharkMainWindow::exportTLSSessionKeys() { QString file_name; QString save_title; @@ -1963,12 +1947,7 @@ void WiresharkMainWindow::on_actionFileExportTLSSessionKeys_triggered() } } -void WiresharkMainWindow::on_actionStatisticsHpfeeds_triggered() -{ - openStatisticsTreeDialog("hpfeeds"); -} - -void WiresharkMainWindow::on_actionFilePrint_triggered() +void WiresharkMainWindow::printFile() { capture_file *cf = capture_file_.capFile(); g_return_if_fail(cf); @@ -3028,6 +3007,13 @@ void WiresharkMainWindow::statCommandExpertInfo(const char *, void *) expert_dialog->show(); } +void WiresharkMainWindow::on_actionAnalyzeShowPacketBytes_triggered() +{ + ShowPacketBytesDialog *spbd = new ShowPacketBytesDialog(*this, capture_file_); + spbd->addCodecs(text_codec_map_); + spbd->show(); +} + void WiresharkMainWindow::on_actionAnalyzeExpertInfo_triggered() { statCommandExpertInfo(NULL, NULL); @@ -3247,6 +3233,11 @@ void WiresharkMainWindow::on_actionStatisticsHART_IP_triggered() openStatisticsTreeDialog("hart_ip"); } +void WiresharkMainWindow::on_actionStatisticsHpfeeds_triggered() +{ + openStatisticsTreeDialog("hpfeeds"); +} + void WiresharkMainWindow::on_actionStatisticsHTTPPacketCounter_triggered() { openStatisticsTreeDialog("http");