From 0a0598949a88cf3342c3cb6360e6f74eeb74e08a Mon Sep 17 00:00:00 2001 From: Gerald Combs Date: Wed, 23 Sep 2015 14:54:25 -0700 Subject: Qt: Show keyboard shortcuts in the about box. Add a "Keyboard Shortcuts" tab to the about box for lack of a better place. Show every action in the main window which has an associated shortcut except for recent items. We might want to add a command-line option to dump the shortcuts in addition to or instead of showing them here. Change-Id: I875043048a44930391fefcbbaf17c5b10a7bb8c6 Reviewed-on: https://code.wireshark.org/review/10634 Reviewed-by: Gerald Combs --- ui/qt/about_dialog.cpp | 41 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) (limited to 'ui/qt/about_dialog.cpp') diff --git a/ui/qt/about_dialog.cpp b/ui/qt/about_dialog.cpp index e5f3683e59..020086c1e1 100644 --- a/ui/qt/about_dialog.cpp +++ b/ui/qt/about_dialog.cpp @@ -56,6 +56,7 @@ #include "qt_ui_utils.h" #include +#include #include #include @@ -116,7 +117,7 @@ const QString AboutDialog::plugins_scan() return plugin_table; } -AboutDialog::AboutDialog(QWidget *) : +AboutDialog::AboutDialog(QWidget *parent) : QDialog(NULL), ui(new Ui::AboutDialog) { @@ -267,6 +268,44 @@ AboutDialog::AboutDialog(QWidget *) : message += ""; ui->label_plugins->setText(message); + /* Shortcuts */ + bool have_shortcuts = false; + + if (parent) { + message = QString("\n").arg(one_em / 4); + message += "\n"; + + QMap > shortcuts; // name -> (shortcut, description) + foreach (const QWidget *child, parent->findChildren()) { + // Recent items look funny here. + if (child->objectName().compare("menuOpenRecentCaptureFile") == 0) continue; + foreach (const QAction *action, child->actions()) { + + if (!action->shortcut().isEmpty()) { + QString name = action->text(); + name.replace('&', ""); + shortcuts[name] = QPair(action->shortcut().toString(QKeySequence::NativeText), action->toolTip()); + } + } + } + + QStringList names = shortcuts.keys(); + names.sort(); + foreach (const QString &name, names) { + message += QString("\n") + .arg(shortcuts[name].first) + .arg(name) + .arg(shortcuts[name].second); + have_shortcuts = true; + } + + message += "
ShortcutNameDescription
%1%2%3
"; + ui->te_shortcuts->setHtml(message); + + } + + ui->te_shortcuts->setVisible(have_shortcuts); + /* License */ #if defined(_WIN32) -- cgit v1.2.1