mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#4176 Add feature to cafCmdFeatureManager to find commands matching a keyboard shortcut
This commit is contained in:
parent
ab3820fe4f
commit
f066829a0f
@ -45,6 +45,7 @@
|
||||
#include "defaultfeatures/cafCmdAddItemFeature.h"
|
||||
|
||||
#include <QAction>
|
||||
#include <QKeySequence>
|
||||
|
||||
namespace caf
|
||||
{
|
||||
@ -313,4 +314,27 @@ std::vector<CmdFeature*> CmdFeatureManager::commandFeaturesMatchingSubString(con
|
||||
return matches;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<CmdFeature*> CmdFeatureManager::commandFeaturesMatchingKeyboardShortcut(const QKeySequence& keySequence) const
|
||||
{
|
||||
std::vector<CmdFeature*> matches;
|
||||
|
||||
std::vector<std::string> keys = CommandFeatureFactory::instance()->allKeys();
|
||||
for (size_t i = 0; i < keys.size(); i++)
|
||||
{
|
||||
caf::CmdFeature* cmdFeature = commandFeature(keys[i]);
|
||||
if (cmdFeature)
|
||||
{
|
||||
if (cmdFeature->action()->shortcut().matches(keySequence) == QKeySequence::ExactMatch)
|
||||
{
|
||||
matches.push_back(cmdFeature);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return matches;
|
||||
}
|
||||
|
||||
} // end namespace caf
|
||||
|
@ -45,6 +45,7 @@
|
||||
#include <QStringList>
|
||||
|
||||
class QAction;
|
||||
class QKeySequence;
|
||||
|
||||
namespace caf
|
||||
{
|
||||
@ -72,7 +73,7 @@ public:
|
||||
CmdFeature* getCommandFeature(const std::string& commandId);
|
||||
|
||||
std::vector<CmdFeature*> commandFeaturesMatchingSubString(const std::string& subString) const;
|
||||
|
||||
std::vector<CmdFeature*> commandFeaturesMatchingKeyboardShortcut(const QKeySequence& keySequence) const;
|
||||
private:
|
||||
CmdFeatureManager();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user