Fcitx
inputmethodentry.cpp
1 /*
2  * SPDX-FileCopyrightText: 2017-2017 CSSlayer <wengxt@gmail.com>
3  *
4  * SPDX-License-Identifier: LGPL-2.1-or-later
5  *
6  */
7 
8 #include "inputmethodentry.h"
9 
10 namespace fcitx {
11 
13 public:
14  InputMethodEntryPrivate(const std::string &uniqueName,
15  const std::string &name,
16  const std::string &languageCode,
17  const std::string &addon)
18  : uniqueName_(uniqueName), name_(name), languageCode_(languageCode),
19  addon_(addon) {}
20 
21  std::string uniqueName_;
22  std::string name_;
23  std::string nativeName_;
24  std::string icon_;
25  std::string label_;
26  std::string languageCode_;
27  std::string addon_;
28  bool configurable_ = false;
29  std::unique_ptr<InputMethodEntryUserData> userData_;
30 };
31 
32 InputMethodEntry::InputMethodEntry(const std::string &uniqueName,
33  const std::string &name,
34  const std::string &languageCode,
35  const std::string &addon)
36  : d_ptr(std::make_unique<InputMethodEntryPrivate>(uniqueName, name,
37  languageCode, addon)) {}
38 
39 FCITX_DEFINE_DEFAULT_DTOR_AND_MOVE(InputMethodEntry)
40 
42 InputMethodEntry::setNativeName(const std::string &nativeName) {
43  FCITX_D();
44  d->nativeName_ = nativeName;
45  return *this;
46 }
47 
48 InputMethodEntry &InputMethodEntry::setIcon(const std::string &icon) {
49  FCITX_D();
50  d->icon_ = icon;
51  return *this;
52 }
53 
54 InputMethodEntry &InputMethodEntry::setLabel(const std::string &label) {
55  FCITX_D();
56  d->label_ = label;
57  return *this;
58 }
59 
60 InputMethodEntry &InputMethodEntry::setConfigurable(bool configurable) {
61  FCITX_D();
62  d->configurable_ = configurable;
63  return *this;
64 }
65 
66 void InputMethodEntry::setUserData(
67  std::unique_ptr<InputMethodEntryUserData> userData) {
68  FCITX_D();
69  d->userData_ = std::move(userData);
70 }
71 
72 const InputMethodEntryUserData *InputMethodEntry::userData() const {
73  FCITX_D();
74  return d->userData_.get();
75 }
76 
77 const std::string &InputMethodEntry::name() const {
78  FCITX_D();
79  return d->name_;
80 }
81 const std::string &InputMethodEntry::nativeName() const {
82  FCITX_D();
83  return d->nativeName_;
84 }
85 const std::string &InputMethodEntry::icon() const {
86  FCITX_D();
87  return d->icon_;
88 }
89 const std::string &InputMethodEntry::uniqueName() const {
90  FCITX_D();
91  return d->uniqueName_;
92 }
93 const std::string &InputMethodEntry::languageCode() const {
94  FCITX_D();
95  return d->languageCode_;
96 }
97 const std::string &InputMethodEntry::addon() const {
98  FCITX_D();
99  return d->addon_;
100 }
101 const std::string &InputMethodEntry::label() const {
102  FCITX_D();
103  return d->label_;
104 }
105 bool InputMethodEntry::isConfigurable() const {
106  FCITX_D();
107  return d->configurable_;
108 }
110  FCITX_D();
111  return d->uniqueName_.starts_with("keyboard-") && d->addon_ == "keyboard";
112 }
113 } // namespace fcitx
bool isKeyboard() const
Helper function to check if this is a keyboard input method.
const std::string & label() const
A compact label that intended to be shown in a compact space.
Definition: action.cpp:17