From f26c8125b8181d7eefd486b1dd89a02a24f6b1e8 Mon Sep 17 00:00:00 2001 From: Qijia Liu Date: Sun, 9 Jun 2024 16:18:57 -0400 Subject: [PATCH] add hotkey configuration for deploy and synchronize --- src/rimeengine.cpp | 12 ++++++++++++ src/rimeengine.h | 7 ++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/rimeengine.cpp b/src/rimeengine.cpp index 94cd656..25b9f4d 100644 --- a/src/rimeengine.cpp +++ b/src/rimeengine.cpp @@ -403,6 +403,9 @@ void RimeEngine::updateConfig() { updateSchemaMenu(); refreshSessionPoolPolicy(); + deployAction_.setHotkey(config_.deploy.value()); + syncAction_.setHotkey(config_.synchronize.value()); + if (constructed_) { refreshStatusArea(0); } @@ -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); diff --git a/src/rimeengine.h b/src/rimeengine.h index d96470d..3ecc012 100644 --- a/src/rimeengine.h +++ b/src/rimeengine.h @@ -100,7 +100,12 @@ FCITX_CONFIGURATION( Option> modules{this, "Modules", _("Modules"), std::vector()}; #endif -); + fcitx::Option deploy{ + this, "Deploy", _("Deploy"), + isApple() ? fcitx::KeyList{fcitx::Key("Control+Alt+grave")} + : fcitx::KeyList{}}; + fcitx::Option synchronize{ + this, "Synchronize", _("Synchronize"), {}};); class RimeEngine final : public InputMethodEngineV2 { public: