Fcitx
inputmethodentry.h
1 /*
2  * SPDX-FileCopyrightText: 2016-2016 CSSlayer <wengxt@gmail.com>
3  *
4  * SPDX-License-Identifier: LGPL-2.1-or-later
5  *
6  */
7 #ifndef _FCITX_INPUTMETHODENTRY_H_
8 #define _FCITX_INPUTMETHODENTRY_H_
9 
10 #include <memory>
11 #include <string>
12 #include <fcitx-utils/macros.h>
13 #include <fcitx/fcitxcore_export.h>
14 
15 namespace fcitx {
16 
17 struct FCITXCORE_EXPORT InputMethodEntryUserData {
18  virtual ~InputMethodEntryUserData() = default;
19 };
20 
22 
23 class FCITXCORE_EXPORT InputMethodEntry {
24 public:
25  InputMethodEntry(const std::string &uniqueName, const std::string &name,
26  const std::string &languageCode, const std::string &addon);
27  InputMethodEntry(const InputMethodEntry &) = delete;
28  FCITX_DECLARE_VIRTUAL_DTOR_MOVE(InputMethodEntry)
29 
30  InputMethodEntry &setNativeName(const std::string &nativeName);
31  InputMethodEntry &setIcon(const std::string &icon);
32  InputMethodEntry &setLabel(const std::string &label);
33  InputMethodEntry &setConfigurable(bool configurable);
34  void setUserData(std::unique_ptr<InputMethodEntryUserData> userData);
35 
36  const InputMethodEntryUserData *userData() const;
37 
38  const std::string &name() const;
39  const std::string &nativeName() const;
40  const std::string &icon() const;
41  const std::string &uniqueName() const;
42  const std::string &languageCode() const;
43  const std::string &addon() const;
44  /**
45  * A compact label that intented to be shown in a compact space.
46  *
47  * usually some latin-character, or a single character of the input method
48  * language.
49  *
50  * UI may choose to strip it to a shorter version if the content is too
51  * long. For example, classicui will take the first section of text to make
52  * it fit with in 3 character width. custom -> cus fr-tg -> fr mon-a1 -> mon
53  * us (intl) -> us
54  *
55  * @return label text
56  */
57  const std::string &label() const;
58  bool isConfigurable() const;
59 
60  /**
61  * Helper function to check if this is a keyboard input method.
62  *
63  * @return is keyboard or not.
64  */
65  bool isKeyboard() const;
66 
67 private:
68  std::unique_ptr<InputMethodEntryPrivate> d_ptr;
69  FCITX_DECLARE_PRIVATE(InputMethodEntry);
70 };
71 } // namespace fcitx
72 
73 #endif // _FCITX_INPUTMETHODENTRY_H_
Definition: action.cpp:17