diff options
author | Gerald Combs <gerald@wireshark.org> | 2015-09-23 14:54:25 -0700 |
---|---|---|
committer | Gerald Combs <gerald@wireshark.org> | 2015-09-24 15:11:46 +0000 |
commit | 0a0598949a88cf3342c3cb6360e6f74eeb74e08a (patch) | |
tree | e9b024598b8c192f14a49fadc418df80a7a82290 /ui/qt/about_dialog.cpp | |
parent | af0e93c05685c8e3ffdca0d48b947767860105a9 (diff) | |
download | wireshark-0a0598949a88cf3342c3cb6360e6f74eeb74e08a.tar.gz |
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 <gerald@wireshark.org>
Diffstat (limited to 'ui/qt/about_dialog.cpp')
-rw-r--r-- | ui/qt/about_dialog.cpp | 41 |
1 files changed, 40 insertions, 1 deletions
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 <QFontMetrics> +#include <QKeySequence> #include <QTextStream> #include <QUrl> @@ -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 += "</table>"; ui->label_plugins->setText(message); + /* Shortcuts */ + bool have_shortcuts = false; + + if (parent) { + message = QString("<table cellpadding=\"%1\">\n").arg(one_em / 4); + message += "<tr><th align=\"left\">Shortcut</th><th align=\"left\">Name</th><th align=\"left\">Description</th></tr>\n"; + + QMap<QString, QPair<QString, QString> > shortcuts; // name -> (shortcut, description) + foreach (const QWidget *child, parent->findChildren<QWidget *>()) { + // 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<QString, QString>(action->shortcut().toString(QKeySequence::NativeText), action->toolTip()); + } + } + } + + QStringList names = shortcuts.keys(); + names.sort(); + foreach (const QString &name, names) { + message += QString("<tr><td>%1</td><td>%2</td><td>%3</td></tr>\n") + .arg(shortcuts[name].first) + .arg(name) + .arg(shortcuts[name].second); + have_shortcuts = true; + } + + message += "</table>"; + ui->te_shortcuts->setHtml(message); + + } + + ui->te_shortcuts->setVisible(have_shortcuts); + /* License */ #if defined(_WIN32) |