From 7a1a45c5234e64286452863088bb9552922b2b3c Mon Sep 17 00:00:00 2001 From: Roland Knall Date: Tue, 12 Nov 2019 12:54:28 +0100 Subject: Qt: Signal empty display filter bar If a display filter is applied, but the display filter bar has been cleared by deleting the context (either by setting a space or backspacing over the filter), it is not clearly indicated that the filter is still being applied. Bug: 12438 Change-Id: Ibd4c48b094467182ed51e9859e0d5fad770000c7 Reviewed-on: https://code.wireshark.org/review/35070 Petri-Dish: Roland Knall Petri-Dish: Anders Broman Tested-by: Petri Dish Buildbot Reviewed-by: Roland Knall --- ui/qt/widgets/display_filter_edit.cpp | 18 ++++++++++++++---- ui/qt/widgets/display_filter_edit.h | 1 + 2 files changed, 15 insertions(+), 4 deletions(-) (limited to 'ui/qt') diff --git a/ui/qt/widgets/display_filter_edit.cpp b/ui/qt/widgets/display_filter_edit.cpp index 1a4458c904..29d036a397 100644 --- a/ui/qt/widgets/display_filter_edit.cpp +++ b/ui/qt/widgets/display_filter_edit.cpp @@ -69,7 +69,8 @@ DisplayFilterEdit::DisplayFilterEdit(QWidget *parent, DisplayFilterEditType type bookmark_button_(NULL), clear_button_(NULL), apply_button_(NULL), - leftAlignActions_(false) + leftAlignActions_(false), + last_applied_(QString()) { setAccessibleName(tr("Display filter entry")); @@ -333,8 +334,10 @@ void DisplayFilterEdit::checkFilter(const QString& filter_text) if ( filter_text.length() > 0 ) clear_button_->setVisible(true); - else - setPlaceholderText(""); + else if ( last_applied_.length() > 0 ) + setPlaceholderText(tr("Current filter: %1").arg(last_applied_)); + else if ( filter_text.length() <= 0 && last_applied_.length() <= 0 ) + clear_button_->setVisible(false); alignActionButtons(); } @@ -548,6 +551,7 @@ void DisplayFilterEdit::clearFilter() { clear(); + last_applied_ = QString(); updateClearButton(); emit filterPackets(QString(), true); @@ -558,6 +562,9 @@ void DisplayFilterEdit::applyDisplayFilter() if (syntaxState() == Invalid) return; + if ( text().length() > 0 ) + last_applied_ = text(); + updateClearButton(); emit filterPackets(text(), true); @@ -642,7 +649,9 @@ void DisplayFilterEdit::applyOrPrepareFilter() if ( ! pa || pa->property("display_filter").toString().isEmpty() ) return; - setText(pa->property("display_filter").toString()); + QString filterText = pa->property("display_filter").toString(); + last_applied_ = filterText; + setText(filterText); // Holding down the Shift key will only prepare filter. if (!(QApplication::keyboardModifiers() & Qt::ShiftModifier)) { @@ -730,6 +739,7 @@ void DisplayFilterEdit::dropEvent(QDropEvent *event) return; } + last_applied_ = filterText; setText(filterText); // Holding down the Shift key will only prepare filter. diff --git a/ui/qt/widgets/display_filter_edit.h b/ui/qt/widgets/display_filter_edit.h index a87adca67f..d3b181dff7 100644 --- a/ui/qt/widgets/display_filter_edit.h +++ b/ui/qt/widgets/display_filter_edit.h @@ -75,6 +75,7 @@ private: StockIconToolButton *clear_button_; StockIconToolButton *apply_button_; bool leftAlignActions_; + QString last_applied_; void setDefaultPlaceholderText(); void buildCompletionList(const QString& field_word); -- cgit v1.2.3