Qt: More menu action cleanup.

We use the convention "actionSomeThing" for action names. Rename some
member functions that used that convention.

Manually connect another action.
This commit is contained in:
Gerald Combs 2022-09-23 17:23:01 -07:00
parent ca2e561a5b
commit 24a09965e6
4 changed files with 38 additions and 42 deletions

View File

@ -318,10 +318,10 @@ private slots:
void mainStackChanged(int); void mainStackChanged(int);
void updateRecentCaptures(); void updateRecentCaptures();
void recentActionTriggered(); void recentActionTriggered();
void actionAddPacketComment(); void addPacketComment();
void actionEditPacketComment(); void editPacketComment();
void actionDeletePacketComment(); void deletePacketComment();
void actionDeleteCommentsFromPackets(); void deleteCommentsFromPackets();
QString commentToMenuText(QString text, int max_len = 40); QString commentToMenuText(QString text, int max_len = 40);
void setEditCommentsMenu(); void setEditCommentsMenu();
void setMenusForSelectedPacket(); void setMenusForSelectedPacket();
@ -398,11 +398,10 @@ private slots:
void findPacket(); void findPacket();
void editTimeShift(); void editTimeShift();
void editConfigurationProfiles(); void editConfigurationProfiles();
void editTimeShiftFinished(int); void editTimeShiftFinished(int);
void addPacketCommentFinished(PacketCommentDialog* pc_dialog, int result); void addPacketCommentFinished(PacketCommentDialog* pc_dialog, int result);
void editPacketCommentFinished(PacketCommentDialog* pc_dialog, int result, guint nComment); void editPacketCommentFinished(PacketCommentDialog* pc_dialog, int result, guint nComment);
void on_actionDeleteAllPacketComments_triggered(); void deleteAllPacketComments();
void deleteAllPacketCommentsFinished(int result); void deleteAllPacketCommentsFinished(int result);
void showPreferencesDialog(QString module_name); void showPreferencesDialog(QString module_name);
@ -512,7 +511,6 @@ private slots:
void on_actionStatisticsEndpoints_triggered(); void on_actionStatisticsEndpoints_triggered();
void on_actionStatisticsPacketLengths_triggered(); void on_actionStatisticsPacketLengths_triggered();
void on_actionStatisticsIOGraph_triggered(); void on_actionStatisticsIOGraph_triggered();
void actionStatisticsPlugin_triggered();
void externalMenuItem_triggered(); void externalMenuItem_triggered();

View File

@ -1562,7 +1562,12 @@ void LograyMainWindow::addStatsPluginsToMenu() {
stats_tree_action = new QAction(stat_name, this); stats_tree_action = new QAction(stat_name, this);
stats_tree_action->setData(cfg->abbr); stats_tree_action->setData(cfg->abbr);
parent_menu->addAction(stats_tree_action); parent_menu->addAction(stats_tree_action);
connect(stats_tree_action, SIGNAL(triggered()), this, SLOT(actionStatisticsPlugin_triggered())); connect(stats_tree_action, &QAction::triggered, this, [this]() {
QAction* action = qobject_cast<QAction*>(sender());
if (action) {
openStatisticsTreeDialog(action->data().toString().toUtf8());
}
});
} }
} }
g_list_free(cfg_list); g_list_free(cfg_list);
@ -1917,6 +1922,9 @@ void LograyMainWindow::connectEditMenuActions()
connect(main_ui_->actionEditTimeShift, &QAction::triggered, this, connect(main_ui_->actionEditTimeShift, &QAction::triggered, this,
[this]() { editTimeShift(); }, Qt::QueuedConnection); [this]() { editTimeShift(); }, Qt::QueuedConnection);
connect(main_ui_->actionDeleteAllPacketComments, &QAction::triggered, this,
[this]() { deleteAllPacketComments(); }, Qt::QueuedConnection);
connect(main_ui_->actionEditConfigurationProfiles, &QAction::triggered, this, connect(main_ui_->actionEditConfigurationProfiles, &QAction::triggered, this,
[this]() { editConfigurationProfiles(); }, Qt::QueuedConnection); [this]() { editConfigurationProfiles(); }, Qt::QueuedConnection);
@ -2058,7 +2066,7 @@ void LograyMainWindow::editTimeShiftFinished(int)
} }
} }
void LograyMainWindow::actionAddPacketComment() void LograyMainWindow::addPacketComment()
{ {
QList<int> rows = selectedRows(); QList<int> rows = selectedRows();
if (rows.count() == 0) if (rows.count() == 0)
@ -2084,7 +2092,7 @@ void LograyMainWindow::addPacketCommentFinished(PacketCommentDialog* pc_dialog _
} }
} }
void LograyMainWindow::actionEditPacketComment() void LograyMainWindow::editPacketComment()
{ {
QList<int> rows = selectedRows(); QList<int> rows = selectedRows();
if (rows.count() != 1) if (rows.count() != 1)
@ -2108,7 +2116,7 @@ void LograyMainWindow::editPacketCommentFinished(PacketCommentDialog* pc_dialog
} }
} }
void LograyMainWindow::actionDeletePacketComment() void LograyMainWindow::deletePacketComment()
{ {
QAction *ra = qobject_cast<QAction*>(sender()); QAction *ra = qobject_cast<QAction*>(sender());
guint nComment = ra->data().toUInt(); guint nComment = ra->data().toUInt();
@ -2116,13 +2124,13 @@ void LograyMainWindow::actionDeletePacketComment()
updateForUnsavedChanges(); updateForUnsavedChanges();
} }
void LograyMainWindow::actionDeleteCommentsFromPackets() void LograyMainWindow::deleteCommentsFromPackets()
{ {
packet_list_->deleteCommentsFromPackets(); packet_list_->deleteCommentsFromPackets();
updateForUnsavedChanges(); updateForUnsavedChanges();
} }
void LograyMainWindow::on_actionDeleteAllPacketComments_triggered() void LograyMainWindow::deleteAllPacketComments()
{ {
QMessageBox *msg_dialog = new QMessageBox(); QMessageBox *msg_dialog = new QMessageBox();
connect(msg_dialog, SIGNAL(finished(int)), this, SLOT(deleteAllPacketCommentsFinished(int))); connect(msg_dialog, SIGNAL(finished(int)), this, SLOT(deleteAllPacketCommentsFinished(int)));
@ -2831,14 +2839,6 @@ void LograyMainWindow::on_actionStatisticsIOGraph_triggered()
iog_dialog->show(); iog_dialog->show();
} }
void LograyMainWindow::actionStatisticsPlugin_triggered()
{
QAction* action = qobject_cast<QAction*>(sender());
if (action) {
openStatisticsTreeDialog(action->data().toString().toUtf8());
}
}
// Tools Menu // Tools Menu
// XXX No log tools yet // XXX No log tools yet

View File

@ -341,10 +341,10 @@ private slots:
void mainStackChanged(int); void mainStackChanged(int);
void updateRecentCaptures(); void updateRecentCaptures();
void recentActionTriggered(); void recentActionTriggered();
void actionAddPacketComment(); void addPacketComment();
void actionEditPacketComment(); void editPacketComment();
void actionDeletePacketComment(); void deletePacketComment();
void actionDeleteCommentsFromPackets(); void deleteCommentsFromPackets();
QString commentToMenuText(QString text, int max_len = 40); QString commentToMenuText(QString text, int max_len = 40);
void setEditCommentsMenu(); void setEditCommentsMenu();
void setMenusForSelectedPacket(); void setMenusForSelectedPacket();
@ -423,11 +423,10 @@ private slots:
void findPacket(); void findPacket();
void editTimeShift(); void editTimeShift();
void editConfigurationProfiles(); void editConfigurationProfiles();
void editTimeShiftFinished(int); void editTimeShiftFinished(int);
void addPacketCommentFinished(PacketCommentDialog* pc_dialog, int result); void addPacketCommentFinished(PacketCommentDialog* pc_dialog, int result);
void editPacketCommentFinished(PacketCommentDialog* pc_dialog, int result, guint nComment); void editPacketCommentFinished(PacketCommentDialog* pc_dialog, int result, guint nComment);
void on_actionDeleteAllPacketComments_triggered(); void deleteAllPacketComments();
void deleteAllPacketCommentsFinished(int result); void deleteAllPacketCommentsFinished(int result);
void showPreferencesDialog(QString module_name); void showPreferencesDialog(QString module_name);
@ -579,7 +578,6 @@ private slots:
void on_actionStatisticsIOGraph_triggered(); void on_actionStatisticsIOGraph_triggered();
void on_actionStatisticsSametime_triggered(); void on_actionStatisticsSametime_triggered();
void on_actionStatisticsDNS_triggered(); void on_actionStatisticsDNS_triggered();
void actionStatisticsPlugin_triggered();
void on_actionStatisticsHpfeeds_triggered(); void on_actionStatisticsHpfeeds_triggered();
void on_actionStatisticsHTTP2_triggered(); void on_actionStatisticsHTTP2_triggered();
void on_actionStatisticsSOMEIPmessages_triggered(); void on_actionStatisticsSOMEIPmessages_triggered();

View File

@ -1669,7 +1669,12 @@ void WiresharkMainWindow::addStatsPluginsToMenu() {
stats_tree_action = new QAction(stat_name, this); stats_tree_action = new QAction(stat_name, this);
stats_tree_action->setData(cfg->abbr); stats_tree_action->setData(cfg->abbr);
parent_menu->addAction(stats_tree_action); parent_menu->addAction(stats_tree_action);
connect(stats_tree_action, SIGNAL(triggered()), this, SLOT(actionStatisticsPlugin_triggered())); connect(stats_tree_action, &QAction::triggered, this, [this]() {
QAction* action = qobject_cast<QAction*>(sender());
if (action) {
openStatisticsTreeDialog(action->data().toString().toUtf8());
}
});
} }
} }
g_list_free(cfg_list); g_list_free(cfg_list);
@ -2084,6 +2089,9 @@ void WiresharkMainWindow::connectEditMenuActions()
connect(main_ui_->actionEditTimeShift, &QAction::triggered, this, connect(main_ui_->actionEditTimeShift, &QAction::triggered, this,
[this]() { editTimeShift(); }, Qt::QueuedConnection); [this]() { editTimeShift(); }, Qt::QueuedConnection);
connect(main_ui_->actionDeleteAllPacketComments, &QAction::triggered, this,
[this]() { deleteAllPacketComments(); }, Qt::QueuedConnection);
connect(main_ui_->actionEditConfigurationProfiles, &QAction::triggered, this, connect(main_ui_->actionEditConfigurationProfiles, &QAction::triggered, this,
[this]() { editConfigurationProfiles(); }, Qt::QueuedConnection); [this]() { editConfigurationProfiles(); }, Qt::QueuedConnection);
@ -2225,7 +2233,7 @@ void WiresharkMainWindow::editTimeShiftFinished(int)
} }
} }
void WiresharkMainWindow::actionAddPacketComment() void WiresharkMainWindow::addPacketComment()
{ {
QList<int> rows = selectedRows(); QList<int> rows = selectedRows();
if (rows.count() == 0) if (rows.count() == 0)
@ -2251,7 +2259,7 @@ void WiresharkMainWindow::addPacketCommentFinished(PacketCommentDialog* pc_dialo
} }
} }
void WiresharkMainWindow::actionEditPacketComment() void WiresharkMainWindow::editPacketComment()
{ {
QList<int> rows = selectedRows(); QList<int> rows = selectedRows();
if (rows.count() != 1) if (rows.count() != 1)
@ -2275,7 +2283,7 @@ void WiresharkMainWindow::editPacketCommentFinished(PacketCommentDialog* pc_dial
} }
} }
void WiresharkMainWindow::actionDeletePacketComment() void WiresharkMainWindow::deletePacketComment()
{ {
QAction *ra = qobject_cast<QAction*>(sender()); QAction *ra = qobject_cast<QAction*>(sender());
guint nComment = ra->data().toUInt(); guint nComment = ra->data().toUInt();
@ -2283,13 +2291,13 @@ void WiresharkMainWindow::actionDeletePacketComment()
updateForUnsavedChanges(); updateForUnsavedChanges();
} }
void WiresharkMainWindow::actionDeleteCommentsFromPackets() void WiresharkMainWindow::deleteCommentsFromPackets()
{ {
packet_list_->deleteCommentsFromPackets(); packet_list_->deleteCommentsFromPackets();
updateForUnsavedChanges(); updateForUnsavedChanges();
} }
void WiresharkMainWindow::on_actionDeleteAllPacketComments_triggered() void WiresharkMainWindow::deleteAllPacketComments()
{ {
QMessageBox *msg_dialog = new QMessageBox(); QMessageBox *msg_dialog = new QMessageBox();
connect(msg_dialog, SIGNAL(finished(int)), this, SLOT(deleteAllPacketCommentsFinished(int))); connect(msg_dialog, SIGNAL(finished(int)), this, SLOT(deleteAllPacketCommentsFinished(int)));
@ -3286,14 +3294,6 @@ void WiresharkMainWindow::on_actionStatisticsDNS_triggered()
openStatisticsTreeDialog("dns"); openStatisticsTreeDialog("dns");
} }
void WiresharkMainWindow::actionStatisticsPlugin_triggered()
{
QAction* action = qobject_cast<QAction*>(sender());
if (action) {
openStatisticsTreeDialog(action->data().toString().toUtf8());
}
}
void WiresharkMainWindow::on_actionStatisticsHTTP2_triggered() void WiresharkMainWindow::on_actionStatisticsHTTP2_triggered()
{ {
openStatisticsTreeDialog("http2"); openStatisticsTreeDialog("http2");