Qt: Use elided heading in filter menus

The heading in Apply as Filter and Prepare as Filter may be very
wide for byte arrays. Use ElideRight with an appropriate length
to limit the menu width.

Change-Id: I2b8f5c805d8fd180c23a211fb7a88d16591175d0
Reviewed-on: https://code.wireshark.org/review/37641
Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
This commit is contained in:
Stig Bjørlykke 2020-07-01 13:54:26 +02:00 committed by Anders Broman
parent 1699e50102
commit cb5bb6c99b
1 changed files with 4 additions and 1 deletions

View File

@ -230,7 +230,10 @@ QMenu * FilterAction::createFilterMenu(FilterAction::Action act, QString filter,
QMenu * submenu = new QMenu(title, par);
if (filter.length() > 0)
{
QAction * comment = submenu->addAction(QString("%1: %2").arg(title).arg(filter));
int one_em = submenu->fontMetrics().height();
QString prep_text = QString("%1: %2").arg(title).arg(filter);
prep_text = submenu->fontMetrics().elidedText(prep_text, Qt::ElideRight, one_em * 40);
QAction * comment = submenu->addAction(prep_text);
comment->setEnabled(false);
submenu->addSeparator();
}