-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathshortcut.cpp
More file actions
65 lines (50 loc) · 1.33 KB
/
shortcut.cpp
File metadata and controls
65 lines (50 loc) · 1.33 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include "shortcut.h"
namespace nativeapi {
Shortcut::Shortcut(ShortcutId id, const ShortcutOptions& options)
: id_(id),
accelerator_(options.accelerator),
description_(options.description),
scope_(options.scope),
enabled_(options.enabled),
callback_(options.callback) {}
Shortcut::Shortcut(ShortcutId id, const std::string& accelerator, std::function<void()> callback)
: id_(id),
accelerator_(accelerator),
description_(""),
scope_(ShortcutScope::Global),
enabled_(true),
callback_(callback) {}
Shortcut::~Shortcut() = default;
ShortcutId Shortcut::GetId() const {
return id_;
}
std::string Shortcut::GetAccelerator() const {
return accelerator_;
}
std::string Shortcut::GetDescription() const {
return description_;
}
void Shortcut::SetDescription(const std::string& description) {
description_ = description;
}
ShortcutScope Shortcut::GetScope() const {
return scope_;
}
void Shortcut::SetEnabled(bool enabled) {
enabled_ = enabled;
}
bool Shortcut::IsEnabled() const {
return enabled_;
}
void Shortcut::Invoke() {
if (enabled_ && callback_) {
callback_();
}
}
void Shortcut::SetCallback(std::function<void()> callback) {
callback_ = callback;
}
std::function<void()> Shortcut::GetCallback() const {
return callback_;
}
} // namespace nativeapi