Skip to content

Commit

Permalink
split AddonFactory into a separate file (#126)
Browse files Browse the repository at this point in the history
  • Loading branch information
eagleoflqj authored Nov 13, 2024
1 parent fd8bf83 commit 8f80c36
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 11 deletions.
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ set(RIME_SOURCES
rimecandidate.cpp
rimesession.cpp
rimeaction.cpp
rimefactory.cpp
)

set(RIME_LINK_LIBRARIES
Expand Down
2 changes: 0 additions & 2 deletions src/rimeengine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -793,5 +793,3 @@ PropertyPropagatePolicy RimeEngine::getSharedStatePolicy() {
}

} // namespace fcitx

FCITX_ADDON_FACTORY(fcitx::RimeEngineFactory)
9 changes: 0 additions & 9 deletions src/rimeengine.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#include <fcitx-utils/standardpath.h>
#include <fcitx-utils/stringutils.h>
#include <fcitx/action.h>
#include <fcitx/addonfactory.h>
#include <fcitx/addoninstance.h>
#include <fcitx/addonmanager.h>
#include <fcitx/event.h>
Expand Down Expand Up @@ -234,14 +233,6 @@ class RimeEngine final : public InputMethodEngineV2 {
std::thread::id mainThreadId_ = std::this_thread::get_id();
RimeState *currentKeyEventState_ = nullptr;
};

class RimeEngineFactory : public AddonFactory {
public:
AddonInstance *create(AddonManager *manager) override {
registerDomain("fcitx5-rime", FCITX_INSTALL_LOCALEDIR);
return new RimeEngine(manager->instance());
}
};
} // namespace fcitx

FCITX_DECLARE_LOG_CATEGORY(rime);
Expand Down
20 changes: 20 additions & 0 deletions src/rimefactory.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* SPDX-FileCopyrightText: 2024-2024 CSSlayer <[email protected]>
*
* SPDX-License-Identifier: LGPL-2.1-or-later
*/

#include "rimefactory.h"
#include "rimeengine.h"
#include <fcitx-utils/i18n.h>

namespace fcitx {

AddonInstance *RimeEngineFactory::create(AddonManager *manager) {
registerDomain("fcitx5-rime", FCITX_INSTALL_LOCALEDIR);
return new RimeEngine(manager->instance());
}

} // namespace fcitx

FCITX_ADDON_FACTORY(fcitx::RimeEngineFactory)
20 changes: 20 additions & 0 deletions src/rimefactory.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* SPDX-FileCopyrightText: 2024-2024 CSSlayer <[email protected]>
*
* SPDX-License-Identifier: LGPL-2.1-or-later
*/
#ifndef _FCITX_RIMEFACTORY_H_
#define _FCITX_RIMEFACTORY_H_

#include <fcitx/addonfactory.h>

namespace fcitx {

class RimeEngineFactory : public AddonFactory {
public:
AddonInstance *create(AddonManager *manager) override;
};

} // namespace fcitx

#endif

0 comments on commit 8f80c36

Please sign in to comment.