Skip to content

Commit

Permalink
add hotkey configuration for deploy and synchronize (fcitx#110)
Browse files Browse the repository at this point in the history
  • Loading branch information
eagleoflqj authored and mokapsing committed Jun 13, 2024
1 parent e8fdac1 commit 73c3638
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
12 changes: 12 additions & 0 deletions src/rimeengine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,9 @@ void RimeEngine::updateConfig() {
updateSchemaMenu();
refreshSessionPoolPolicy();

deployAction_.setHotkey(config_.deploy.value());
syncAction_.setHotkey(config_.synchronize.value());

if (constructed_) {
refreshStatusArea(0);
}
Expand Down Expand Up @@ -494,6 +497,15 @@ void RimeEngine::keyEvent(const InputMethodEntry &entry, KeyEvent &event) {
RIME_DEBUG() << "Rime receive key: " << event.rawKey() << " "
<< event.isRelease();
auto *inputContext = event.inputContext();
if (!event.isRelease()) {
if (event.key().checkKeyList(*config_.deploy)) {
deploy();
return event.filterAndAccept();
} else if (event.key().checkKeyList(*config_.synchronize)) {
sync();
return event.filterAndAccept();
}
}
auto *state = this->state(inputContext);
currentKeyEventState_ = state;
state->keyEvent(event);
Expand Down
7 changes: 6 additions & 1 deletion src/rimeengine.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,12 @@ FCITX_CONFIGURATION(
Option<std::vector<std::string>> modules{this, "Modules", _("Modules"),
std::vector<std::string>()};
#endif
);
fcitx::Option<fcitx::KeyList> deploy{
this, "Deploy", _("Deploy"),
isApple() ? fcitx::KeyList{fcitx::Key("Control+Alt+grave")}
: fcitx::KeyList{}};
fcitx::Option<fcitx::KeyList> synchronize{
this, "Synchronize", _("Synchronize"), {}};);

class RimeEngine final : public InputMethodEngineV2 {
public:
Expand Down

0 comments on commit 73c3638

Please sign in to comment.