Fix up keyboard shorcut on < Qt 5.10

This commit is contained in:
Gaute Lindkvist
2019-03-27 12:01:22 +01:00
parent af20545691
commit 3d3868e29d
24 changed files with 52 additions and 50 deletions

View File

@@ -155,6 +155,20 @@ bool CmdFeature::canFeatureBeExecuted()
return this->isCommandEnabled();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void CmdFeature::applyShortcutWithHintToAction(QAction* action, const QKeySequence& keySequence)
{
action->setShortcut(keySequence);
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
// Qt made keyboard shortcuts in context menus platform dependent in Qt 5.10
// With no global way of removing it.
action->setShortcutVisibleInContextMenu(true);
#endif
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@@ -46,6 +46,7 @@
class QAction;
class QIcon;
class QKeySequence;
class QString;
#define CAF_CMD_HEADER_INIT \
@@ -84,6 +85,8 @@ public:
bool canFeatureBeExecuted();
static void applyShortcutWithHintToAction(QAction* action, const QKeySequence& keySequence);
public slots:
void actionTriggered(bool isChecked);

View File

@@ -140,8 +140,7 @@ void CmdDeleteItemFeature::onActionTriggered(bool isChecked)
void CmdDeleteItemFeature::setupActionLook(QAction* actionToSetup)
{
actionToSetup->setText("Delete object");
actionToSetup->setShortcut(QKeySequence::Delete);
actionToSetup->setShortcutVisibleInContextMenu(true);
applyShortcutWithHintToAction(actionToSetup, QKeySequence::Delete);
}
} // end namespace caf