Skip to content

Commit

Permalink
split AddonFactory
Browse files Browse the repository at this point in the history
  • Loading branch information
eagleoflqj committed Nov 13, 2024
1 parent fb57b2c commit 83d9a9b
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
10 changes: 10 additions & 0 deletions src/factory.cpp
Original file line number Diff line number Diff line change
@@ -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);
12 changes: 12 additions & 0 deletions src/factory.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#ifndef _FCITX5_HALLELUJAH_FACTORY_H_
#define _FCITX5_HALLELUJAH_FACTORY_H_

#include <fcitx/addonfactory.h>

namespace fcitx {
class HallelujahFactory : public AddonFactory {
public:
AddonInstance *create(AddonManager *manager) override;
};
} // namespace fcitx
#endif
2 changes: 0 additions & 2 deletions src/hallelujah.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -380,5 +380,3 @@ void HallelujahEngine::setConfig(const RawConfig &config) {
reloadConfig();
}
} // namespace fcitx

FCITX_ADDON_FACTORY(fcitx::HallelujahFactory);
9 changes: 0 additions & 9 deletions src/hallelujah.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include <fcitx-config/iniparser.h>
#include <fcitx-utils/i18n.h>
#include <fcitx-utils/inputbuffer.h>
#include <fcitx/addonfactory.h>
#include <fcitx/addonmanager.h>
#include <fcitx/inputcontext.h>
#include <fcitx/inputcontextproperty.h>
Expand Down Expand Up @@ -90,14 +89,6 @@ class HallelujahEngine final : public InputMethodEngine {
std::unordered_map<std::string, std::vector<std::string>> 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

0 comments on commit 83d9a9b

Please sign in to comment.