2019-03-02 10:04:49 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
2019-09-06 15:34:26 +02:00
|
|
|
#include <AK/String.h>
|
2019-03-02 10:04:49 +01:00
|
|
|
#include <AK/Traits.h>
|
2019-05-28 11:53:16 +02:00
|
|
|
#include <Kernel/KeyCode.h>
|
2019-03-02 10:04:49 +01:00
|
|
|
|
|
|
|
|
class GShortcut {
|
|
|
|
|
public:
|
2019-05-28 11:53:16 +02:00
|
|
|
GShortcut() {}
|
2019-07-03 21:17:35 +02:00
|
|
|
GShortcut(u8 modifiers, KeyCode key)
|
2019-03-02 10:04:49 +01:00
|
|
|
: m_modifiers(modifiers)
|
|
|
|
|
, m_key(key)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool is_valid() const { return m_key != KeyCode::Key_Invalid; }
|
2019-07-03 21:17:35 +02:00
|
|
|
u8 modifiers() const { return m_modifiers; }
|
2019-03-02 10:04:49 +01:00
|
|
|
KeyCode key() const { return m_key; }
|
|
|
|
|
String to_string() const;
|
|
|
|
|
|
|
|
|
|
bool operator==(const GShortcut& other) const
|
|
|
|
|
{
|
|
|
|
|
return m_modifiers == other.m_modifiers
|
|
|
|
|
&& m_key == other.m_key;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private:
|
2019-07-03 21:17:35 +02:00
|
|
|
u8 m_modifiers { 0 };
|
2019-03-02 10:04:49 +01:00
|
|
|
KeyCode m_key { KeyCode::Key_Invalid };
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
namespace AK {
|
|
|
|
|
|
|
|
|
|
template<>
|
2019-06-29 19:14:03 +02:00
|
|
|
struct Traits<GShortcut> : public GenericTraits<GShortcut> {
|
2019-03-02 10:04:49 +01:00
|
|
|
static unsigned hash(const GShortcut& shortcut)
|
|
|
|
|
{
|
|
|
|
|
return pair_int_hash(shortcut.modifiers(), shortcut.key());
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|