InputMapping.h 806 B

12345678910111213141516171819202122232425262728293031323334353637
  1. #ifndef INPUTMAPPING_H
  2. #define INPUTMAPPING_H
  3. #include <QMap>
  4. #include <QObject>
  5. #include <QFileSystemWatcher>
  6. #include <QRegExp>
  7. #include <QVariantMap>
  8. #include <QMutex>
  9. #include <utils/CachedRegexMatcher.h>
  10. class InputMapping : public QObject
  11. {
  12. Q_OBJECT
  13. public:
  14. explicit InputMapping(QObject *parent = nullptr);
  15. bool loadMappings();
  16. QVariantList mapToAction(const QString& source, const QString& keycode);
  17. private Q_SLOTS:
  18. void dirChange();
  19. signals:
  20. void mappingChanged();
  21. private:
  22. bool loadMappingFile(const QString &path, QPair<QString, QVariantMap> &mappingPair);
  23. bool loadMappingDirectory(const QString& path, bool copy);
  24. QFileSystemWatcher* m_watcher;
  25. QHash<QString, CachedRegexMatcher*> m_inputMatcher;
  26. CachedRegexMatcher m_sourceMatcher;
  27. };
  28. #endif // INPUTMAPPING_H