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 8, 2024
1 parent b17ca83 commit 04662a8
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
20 changes: 20 additions & 0 deletions src/rimeengine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<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 @@ -540,6 +557,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 @@ -86,7 +86,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 RimeOptionAction : public Action {
public:
Expand Down Expand Up @@ -196,6 +201,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 04662a8

Please sign in to comment.