# HG changeset patch # User Chris Cannam # Date 1394116079 0 # Node ID a31c8ee2e17ed0da98d3dcc2a787579f3acb40fe # Parent dfe543438d52b937338211d90528b65973c6ec9e Allow registering an alternative shortcut using QKeySequence so as to get the right native string diff -r dfe543438d52 -r a31c8ee2e17e widgets/KeyReference.cpp --- a/widgets/KeyReference.cpp Thu Mar 06 14:03:42 2014 +0000 +++ b/widgets/KeyReference.cpp Thu Mar 06 14:27:59 2014 +0000 @@ -87,6 +87,13 @@ } void +KeyReference::registerAlternativeShortcut(QAction *action, QKeySequence shortcut) +{ + QString name = action->text(); + registerAlternativeShortcut(name, shortcut.toString(QKeySequence::NativeText)); +} + +void KeyReference::registerAlternativeShortcut(QString name, QString alternative) { name.replace(tr("&"), ""); @@ -102,6 +109,12 @@ } void +KeyReference::registerAlternativeShortcut(QString name, QKeySequence shortcut) +{ + registerAlternativeShortcut(name, shortcut.toString(QKeySequence::NativeText)); +} + +void KeyReference::show() { if (m_dialog) { @@ -147,7 +160,7 @@ altdesc = tr(" (%1)").arg(altdesc); } - text += QString(" %1%2 %3%4\n") + text += QString(" %1%2 %3%4\n") .arg(shortcut).arg(altdesc).arg(actionName).arg(tip); } } diff -r dfe543438d52 -r a31c8ee2e17e widgets/KeyReference.h --- a/widgets/KeyReference.h Thu Mar 06 14:03:42 2014 +0000 +++ b/widgets/KeyReference.h Thu Mar 06 14:27:59 2014 +0000 @@ -20,6 +20,7 @@ #include #include #include +#include class QAction; class QTextEdit; @@ -38,9 +39,11 @@ void registerShortcut(QAction *, QString overrideName = ""); void registerAlternativeShortcut(QAction *, QString alternative); + void registerAlternativeShortcut(QAction *, QKeySequence alternative); void registerShortcut(QString actionName, QString shortcut, QString tipText); void registerAlternativeShortcut(QString actionName, QString alternative); + void registerAlternativeShortcut(QString actionName, QKeySequence alternative); void show(); void hide();