diff --git a/CMakeLists.txt b/CMakeLists.txt index 90f94a1..84747cc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,7 +10,7 @@ include(ECMSetupVersion) include(ECMUninstallTarget) find_package(Gettext REQUIRED) -find_package(Fcitx5Core 5.1.10 REQUIRED) +find_package(Fcitx5Core 5.1.11 REQUIRED) find_package(Fcitx5Module REQUIRED COMPONENTS Notifications) find_package(PkgConfig REQUIRED) diff --git a/src/rimeengine.cpp b/src/rimeengine.cpp index 160d257..cfd4180 100644 --- a/src/rimeengine.cpp +++ b/src/rimeengine.cpp @@ -361,6 +361,23 @@ RimeEngine::RimeEngine(Instance *instance) globalConfigReloadHandle_ = instance_->watchEvent( EventType::GlobalConfigReloaded, EventWatcherPhase::Default, [this](Event &) { refreshSessionPoolPolicy(); }); + eventHandler_ = instance_->watchEvent( + EventType::InputContextKeyEvent, EventWatcherPhase::Default, + [this](Event &event) { + auto &keyEvent = static_cast(event); + if (keyEvent.isRelease()) { + return; + } + auto *ic = keyEvent.inputContext(); + if (keyEvent.key().checkKeyList(config_.deploy.value())) { + deploy(); + keyEvent.filterAndAccept(); + } else if (keyEvent.key().checkKeyList( + config_.synchronize.value())) { + sync(); + keyEvent.filterAndAccept(); + } + }); reloadConfig(); constructed_ = true; } @@ -540,6 +557,9 @@ void RimeEngine::updateConfig() { updateSchemaMenu(); refreshSessionPoolPolicy(); + deployAction_.setHotkey(config_.deploy.value()); + syncAction_.setHotkey(config_.synchronize.value()); + if (constructed_) { refreshStatusArea(0); } diff --git a/src/rimeengine.h b/src/rimeengine.h index 2758cde..2df95d5 100644 --- a/src/rimeengine.h +++ b/src/rimeengine.h @@ -86,7 +86,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 RimeOptionAction : public Action { public: @@ -196,6 +201,7 @@ class RimeEngine final : public InputMethodEngineV2 { std::unordered_map pluginPool_; #endif std::unique_ptr> globalConfigReloadHandle_; + std::unique_ptr> eventHandler_; #ifndef FCITX_RIME_NO_DBUS RimeService service_{this};