From 5c60b517a70cab8138312ec39946f18f3ed75f58 Mon Sep 17 00:00:00 2001 From: Michael Mann Date: Sun, 25 Jun 2017 11:48:46 -0400 Subject: Add support for comments for a display filter button Add a field to the display filter button UAT to allow comments to be displayed as part of the tooltip to the diplay filter button Bug: 13814 Change-Id: I74459e4102856258d31d6429e2fd924a9f798cd5 Reviewed-on: https://code.wireshark.org/review/22390 Petri-Dish: Michael Mann Tested-by: Petri Dish Buildbot Reviewed-by: Michael Mann --- ui/gtk/filter_expression_save_dlg.c | 13 +++++++++++-- ui/qt/filter_expression_frame.cpp | 3 ++- ui/qt/filter_expression_frame.ui | 25 ++++++++++++++++++++++++- ui/qt/main_window_slots.cpp | 10 +++++++++- 4 files changed, 46 insertions(+), 5 deletions(-) (limited to 'ui') diff --git a/ui/gtk/filter_expression_save_dlg.c b/ui/gtk/filter_expression_save_dlg.c index d60778d505..6a40dc30d4 100644 --- a/ui/gtk/filter_expression_save_dlg.c +++ b/ui/gtk/filter_expression_save_dlg.c @@ -134,10 +134,11 @@ filter_button_add(const char *label, const char *expr, struct filter_expression { struct filter_expression *fe; GtkWidget *button; + gchar* tooltip; /* No duplicate buttons when adding a new one */ if (newfe == NULL) - fe = filter_expression_new(label, expr, TRUE); + fe = filter_expression_new(label, expr, "", TRUE); else fe = newfe; @@ -153,7 +154,15 @@ filter_button_add(const char *label, const char *expr, struct filter_expression gtk_toolbar_insert(GTK_TOOLBAR(_filter_tb), (GtkToolItem *)button, -1); gtk_widget_set_sensitive(GTK_WIDGET(button), TRUE); - gtk_widget_set_tooltip_text(GTK_WIDGET(button), fe->expression); + if (strlen(fe->comment) > 0) + { + tooltip = g_strdup_printf("%s, %s", fe->expression, fe->comment); + gtk_widget_set_tooltip_text(GTK_WIDGET(button), tooltip); + } + else + { + gtk_widget_set_tooltip_text(GTK_WIDGET(button), fe->expression); + } fe->button = button; filter_buttons = g_list_append (filter_buttons, button); diff --git a/ui/qt/filter_expression_frame.cpp b/ui/qt/filter_expression_frame.cpp index 15fae7eeeb..b67eba6adf 100644 --- a/ui/qt/filter_expression_frame.cpp +++ b/ui/qt/filter_expression_frame.cpp @@ -95,8 +95,9 @@ void FilterExpressionFrame::on_buttonBox_accepted() gchar* err = NULL; QByteArray label_ba = ui->labelLineEdit->text().toUtf8(); QByteArray expr_ba = ui->displayFilterLineEdit->text().toUtf8(); + QByteArray comment_ba = ui->commentLineEdit->text().toUtf8(); - filter_expression_new(label_ba.constData(), expr_ba.constData(), TRUE); + filter_expression_new(label_ba.constData(), expr_ba.constData(), comment_ba.constData(), TRUE); on_buttonBox_rejected(); emit filterExpressionsChanged(); diff --git a/ui/qt/filter_expression_frame.ui b/ui/qt/filter_expression_frame.ui index a20b0ddddc..df9691bfd9 100644 --- a/ui/qt/filter_expression_frame.ui +++ b/ui/qt/filter_expression_frame.ui @@ -105,7 +105,30 @@ - + + + + Comment: + + + + + + + + 1 + 0 + + + + + 80 + 0 + + + + + Qt::Horizontal diff --git a/ui/qt/main_window_slots.cpp b/ui/qt/main_window_slots.cpp index 8f675926d9..1b153ce19a 100644 --- a/ui/qt/main_window_slots.cpp +++ b/ui/qt/main_window_slots.cpp @@ -909,7 +909,15 @@ gboolean MainWindow::filter_expression_add_action(const void *key _U_, void *val return FALSE; QAction *dfb_action = new QAction(fe->label, data->window->filter_expression_toolbar_); - dfb_action->setToolTip(fe->expression); + if (strlen(fe->comment) > 0) + { + QString tooltip = QString("%1, %2").arg(fe->expression).arg(fe->comment); + dfb_action->setToolTip(tooltip); + } + else + { + dfb_action->setToolTip(fe->expression); + } dfb_action->setData(fe->expression); dfb_action->setProperty(dfe_property_, true); data->window->filter_expression_toolbar_->addAction(dfb_action); -- cgit v1.2.1