Skip to content

Commit

Permalink
add hotkey configuration for deploy and synchronize
Browse files Browse the repository at this point in the history
  • Loading branch information
eagleoflqj committed Jun 9, 2024
1 parent 2c471c6 commit c7ece54
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
20 changes: 20 additions & 0 deletions src/rimeengine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,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<KeyEvent &>(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;
}
Expand Down Expand Up @@ -403,6 +420,9 @@ void RimeEngine::updateConfig() {
updateSchemaMenu();
refreshSessionPoolPolicy();

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

if (constructed_) {
refreshStatusArea(0);
}
Expand Down
8 changes: 7 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 Expand Up @@ -206,6 +211,7 @@ class RimeEngine final : public InputMethodEngineV2 {
std::unordered_map<std::string, Library> pluginPool_;
#endif
std::unique_ptr<HandlerTableEntry<EventHandler>> globalConfigReloadHandle_;
std::unique_ptr<HandlerTableEntry<EventHandler>> eventHandler_;

#ifndef FCITX_RIME_NO_DBUS
RimeService service_{this};
Expand Down

0 comments on commit c7ece54

Please sign in to comment.