Qt: Make sure shortcuts are visible in context menus.
As of Qt 5.10, context menu shortcuts can be hidden: https://bugreports.qt.io/browse/QTBUG-61181 Add set_action_shortcuts_visible_in_context_menu to qt_ui_utils and call it for our context menus as needed. For Qt 5.{10,11,12} it calls QAction::setShortcutVisibleInContextMenu(true). For Qt 5.13 and later, call QStyleHints::setShowShortcutsInContextMenus(true) in WiresharkApplication. Change-Id: Ie8941951c3a9801b4642f4ce15ac217e37d1300f Reviewed-on: https://code.wireshark.org/review/35761 Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot Reviewed-by: Gerald Combs <gerald@wireshark.org>
This commit is contained in:
parent
9e135f8748
commit
48024b102d
|
@ -214,6 +214,8 @@ Iax2AnalysisDialog::Iax2AnalysisDialog(QWidget &parent, CaptureFile &cf) :
|
|||
stream_ctx_menu_.addAction(ui->actionSaveReverseCsv);
|
||||
stream_ctx_menu_.addSeparator();
|
||||
stream_ctx_menu_.addAction(ui->actionSaveGraph);
|
||||
set_action_shortcuts_visible_in_context_menu(stream_ctx_menu_.actions());
|
||||
|
||||
ui->forwardTreeWidget->installEventFilter(this);
|
||||
ui->forwardTreeWidget->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
connect(ui->forwardTreeWidget, SIGNAL(customContextMenuRequested(QPoint)),
|
||||
|
|
|
@ -385,6 +385,7 @@ IOGraphDialog::IOGraphDialog(QWidget &parent, CaptureFile &cf, QString displayFi
|
|||
ctx_menu_.addAction(ui->actionDragZoom);
|
||||
ctx_menu_.addAction(ui->actionToggleTimeOrigin);
|
||||
ctx_menu_.addAction(ui->actionCrosshairs);
|
||||
set_action_shortcuts_visible_in_context_menu(ctx_menu_.actions());
|
||||
|
||||
iop->xAxis->setLabel(tr("Time (s)"));
|
||||
|
||||
|
|
|
@ -93,6 +93,7 @@ LteRlcGraphDialog::LteRlcGraphDialog(QWidget &parent, CaptureFile &cf, bool chan
|
|||
ctx_menu_->addAction(ui->actionCrosshairs);
|
||||
ctx_menu_->addSeparator();
|
||||
ctx_menu_->addAction(ui->actionSwitchDirection);
|
||||
set_action_shortcuts_visible_in_context_menu(ctx_menu_->actions());
|
||||
|
||||
// Zero out this struct.
|
||||
memset(&graph_, 0, sizeof(graph_));
|
||||
|
|
|
@ -267,6 +267,8 @@ RtpAnalysisDialog::RtpAnalysisDialog(QWidget &parent, CaptureFile &cf, rtpstream
|
|||
stream_ctx_menu_.addAction(ui->actionSaveReverseCsv);
|
||||
stream_ctx_menu_.addSeparator();
|
||||
stream_ctx_menu_.addAction(ui->actionSaveGraph);
|
||||
set_action_shortcuts_visible_in_context_menu(stream_ctx_menu_.actions());
|
||||
|
||||
ui->forwardTreeWidget->installEventFilter(this);
|
||||
ui->forwardTreeWidget->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
ui->forwardTreeWidget->header()->setSortIndicator(0, Qt::AscendingOrder);
|
||||
|
|
|
@ -127,6 +127,7 @@ RtpPlayerDialog::RtpPlayerDialog(QWidget &parent, CaptureFile &cf) :
|
|||
ctx_menu_->addAction(ui->actionDragZoom);
|
||||
ctx_menu_->addAction(ui->actionToggleTimeOrigin);
|
||||
// ctx_menu_->addAction(ui->actionCrosshairs);
|
||||
set_action_shortcuts_visible_in_context_menu(ctx_menu_->actions());
|
||||
|
||||
connect(ui->audioPlot, SIGNAL(mouseMove(QMouseEvent*)),
|
||||
this, SLOT(updateHintLabel()));
|
||||
|
|
|
@ -219,6 +219,8 @@ RtpStreamDialog::RtpStreamDialog(QWidget &parent, CaptureFile &cf) :
|
|||
ctx_menu_.addAction(ui->actionCopyAsCsv);
|
||||
ctx_menu_.addAction(ui->actionCopyAsYaml);
|
||||
ctx_menu_.addAction(ui->actionAnalyze);
|
||||
set_action_shortcuts_visible_in_context_menu(ctx_menu_.actions());
|
||||
|
||||
ui->streamTreeWidget->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
ui->streamTreeWidget->header()->setSortIndicator(0, Qt::AscendingOrder);
|
||||
connect(ui->streamTreeWidget, SIGNAL(customContextMenuRequested(QPoint)),
|
||||
|
|
|
@ -145,6 +145,7 @@ SequenceDialog::SequenceDialog(QWidget &parent, CaptureFile &cf, SequenceInfo *i
|
|||
ctx_menu_.addAction(ui->actionGoToPacket);
|
||||
ctx_menu_.addAction(ui->actionGoToNextPacket);
|
||||
ctx_menu_.addAction(ui->actionGoToPreviousPacket);
|
||||
set_action_shortcuts_visible_in_context_menu(ctx_menu_.actions());
|
||||
|
||||
ui->addressComboBox->setCurrentIndex(0);
|
||||
|
||||
|
|
|
@ -175,6 +175,7 @@ TCPStreamDialog::TCPStreamDialog(QWidget *parent, capture_file *cf, tcp_graph_ty
|
|||
ctx_menu_.addAction(ui->actionStevens);
|
||||
ctx_menu_.addAction(ui->actionTcptrace);
|
||||
ctx_menu_.addAction(ui->actionWindowScaling);
|
||||
set_action_shortcuts_visible_in_context_menu(ctx_menu_.actions());
|
||||
|
||||
memset (&graph_, 0, sizeof(graph_));
|
||||
graph_.type = graph_type;
|
||||
|
|
|
@ -238,6 +238,19 @@ bool rect_on_screen(const QRect &rect)
|
|||
return false;
|
||||
}
|
||||
|
||||
void set_action_shortcuts_visible_in_context_menu(QList<QAction *> actions)
|
||||
{
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) && QT_VERSION < QT_VERSION_CHECK(5, 13, 0)
|
||||
// For QT_VERSION >= 5.13.0 we call styleHints()->setShowShortcutsInContextMenus(true)
|
||||
// in WiresharkApplication.
|
||||
// QTBUG-71471
|
||||
// QTBUG-61181
|
||||
foreach (QAction *action, actions) {
|
||||
action->setShortcutVisibleInContextMenu(true);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* Editor modelines
|
||||
*
|
||||
|
|
|
@ -223,6 +223,14 @@ void desktop_show_in_folder(const QString file_path);
|
|||
*/
|
||||
bool rect_on_screen(const QRect &rect);
|
||||
|
||||
/**
|
||||
* Set the "shortcutVisibleInContextMenu" property to true for
|
||||
* a list of qactions.
|
||||
*
|
||||
* @param actions The actions to make visible.
|
||||
*/
|
||||
void set_action_shortcuts_visible_in_context_menu(QList<QAction *> actions);
|
||||
|
||||
#endif /* __QT_UI_UTILS__H__ */
|
||||
|
||||
// XXX Add a routine to fetch the HWND corresponding to a widget using QPlatformIntegration
|
||||
|
|
|
@ -93,6 +93,10 @@
|
|||
#include <QFontDatabase>
|
||||
#include <QMimeDatabase>
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0)
|
||||
#include <QStyleHints>
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
@ -748,6 +752,11 @@ WiresharkApplication::WiresharkApplication(int &argc, char **argv) :
|
|||
#endif // Q_OS_WIN
|
||||
|
||||
setAttribute(Qt::AA_UseHighDpiPixmaps);
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0)
|
||||
styleHints()->setShowShortcutsInContextMenus(true);
|
||||
#endif
|
||||
|
||||
//
|
||||
// XXX - this means we try to check for the existence of all files
|
||||
// in the recent list every 2 seconds; that causes noticeable network
|
||||
|
|
Loading…
Reference in New Issue