diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index dcbd627..bf6da01 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,4 +1,4 @@ -add_library(hallelujah MODULE hallelujah.cpp) +add_library(hallelujah MODULE hallelujah.cpp factory.cpp) target_link_libraries(hallelujah Fcitx5::Core Fcitx5::Module::Spell fmt::fmt ${MARISA_TARGET} ${JSONC_TARGET}) install(TARGETS hallelujah DESTINATION "${FCITX_INSTALL_LIBDIR}/fcitx5") fcitx5_translate_desktop_file(hallelujah.conf.in hallelujah.conf) diff --git a/src/factory.cpp b/src/factory.cpp new file mode 100644 index 0000000..803290f --- /dev/null +++ b/src/factory.cpp @@ -0,0 +1,10 @@ +#include "factory.h" +#include "hallelujah.h" + +namespace fcitx { +AddonInstance *HallelujahFactory::create(AddonManager *manager) { + return new HallelujahEngine(manager->instance()); +} +} // namespace fcitx + +FCITX_ADDON_FACTORY(fcitx::HallelujahFactory); diff --git a/src/factory.h b/src/factory.h new file mode 100644 index 0000000..06a8307 --- /dev/null +++ b/src/factory.h @@ -0,0 +1,12 @@ +#ifndef _FCITX5_HALLELUJAH_FACTORY_H_ +#define _FCITX5_HALLELUJAH_FACTORY_H_ + +#include + +namespace fcitx { +class HallelujahFactory : public AddonFactory { +public: + AddonInstance *create(AddonManager *manager) override; +}; +} // namespace fcitx +#endif diff --git a/src/hallelujah.cpp b/src/hallelujah.cpp index aac78cf..197001b 100644 --- a/src/hallelujah.cpp +++ b/src/hallelujah.cpp @@ -380,5 +380,3 @@ void HallelujahEngine::setConfig(const RawConfig &config) { reloadConfig(); } } // namespace fcitx - -FCITX_ADDON_FACTORY(fcitx::HallelujahFactory); diff --git a/src/hallelujah.h b/src/hallelujah.h index 0ab0c36..c9e3aa3 100644 --- a/src/hallelujah.h +++ b/src/hallelujah.h @@ -4,7 +4,6 @@ #include #include #include -#include #include #include #include @@ -90,14 +89,6 @@ class HallelujahEngine final : public InputMethodEngine { std::unordered_map> pinyin_; static const inline std::string ConfPath = "conf/hallelujah.conf"; }; - -class HallelujahFactory : public AddonFactory { -public: - AddonInstance *create(AddonManager *manager) override { - registerDomain("fcitx5-hallelujah", FCITX_INSTALL_LOCALEDIR); - return new HallelujahEngine(manager->instance()); - } -}; } // namespace fcitx #endif