aboutsummaryrefslogtreecommitdiff
path: root/src/keymap/KeySeqParser.hpp
blob: 3772f4eb614ce4bdf3d9ca5cb6289e8f9a690626 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#pragma once

#include <QtCore>
#include <cstdint>

struct KeyChord {
  Qt::KeyboardModifiers mod;
  Qt::Key key;

  bool operator==(const KeyChord &chord2) const;
};

using KeySequence = QList<KeyChord>;

enum KeyMatchType : uint8_t {
  NoMatch,
  Match,
  Pending,
};

class KeySeqParser {
public:
  static KeyMatchType key_sequence_match(const KeySequence &target, const KeySequence &current);

  KeySeqParser() = default;
  KeySequence parse(QString key_sequence);

private:
  Qt::Key parse_key(const QString &key_name);
};