Fcitx
globalconfig.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_GLOBALCONFIG_H_
8 #define _FCITX_GLOBALCONFIG_H_
9 
10 #include <cstdint>
11 #include <memory>
12 #include <string>
13 #include <vector>
14 #include <fcitx-config/configuration.h>
15 #include <fcitx-config/rawconfig.h>
16 #include <fcitx-utils/key.h>
17 #include <fcitx-utils/macros.h>
18 #include <fcitx/fcitxcore_export.h>
19 #include <fcitx/inputcontextmanager.h>
20 
21 namespace fcitx {
22 
23 class GlobalConfigPrivate;
24 
25 class FCITXCORE_EXPORT GlobalConfig {
26 public:
27  GlobalConfig();
28  virtual ~GlobalConfig();
29  const KeyList &triggerKeys() const;
30  bool enumerateWithTriggerKeys() const;
31  const KeyList &altTriggerKeys() const;
32  const KeyList &activateKeys() const;
33  const KeyList &deactivateKeys() const;
34  const KeyList &enumerateForwardKeys() const;
35  const KeyList &enumerateBackwardKeys() const;
36  bool enumerateSkipFirst() const;
37  const KeyList &enumerateGroupForwardKeys() const;
38  const KeyList &enumerateGroupBackwardKeys() const;
39  const KeyList &togglePreeditKeys() const;
40 
41  bool activeByDefault() const;
42 
43  /**
44  * Reset active state to the value of activeByDefault on Focus In.
45  *
46  * @see activeByDefault
47  * @return the reset policy, no for disable, all for always reset, program
48  * for only reset on program changes.
49  * @since 5.1.8
50  */
51  PropertyPropagatePolicy resetStateWhenFocusIn() const;
52  bool showInputMethodInformation() const;
53  bool showInputMethodInformationWhenFocusIn() const;
54  bool compactInputMethodInformation() const;
55  bool showFirstInputMethodInformation() const;
56  PropertyPropagatePolicy shareInputState() const;
57  bool preeditEnabledByDefault() const;
58 
59  const KeyList &defaultPrevPage() const;
60  const KeyList &defaultNextPage() const;
61 
62  const KeyList &defaultPrevCandidate() const;
63  const KeyList &defaultNextCandidate() const;
64  int defaultPageSize() const;
65 
66  /**
67  * Override the xkb option from display.
68  *
69  * This is only useful for custom xkb translation.
70  * Right now there is no way to read system xkb option from wayland.
71  * Instead, we can ask user for the fallback.
72  *
73  * @return override xkb option from system or not
74  * @since 5.0.14
75  */
76  bool overrideXkbOption() const;
77 
78  /**
79  * The enforce the xkb option for custom xkb state.
80  *
81  * This is only useful for custom xkb translation.
82  * Right now there is no way to read system xkb option from wayland.
83  * Instead, we can ask user for the fallback.
84  *
85  * @return override xkb option
86  * @see GlobalConfig::overrideXkbOption
87  * @since 5.0.14
88  */
89  const std::string &customXkbOption() const;
90 
91  /**
92  * Allow use input method in password field.
93  *
94  * @return whether allow use input method in password field.
95  * @since 5.1.2
96  */
97  bool allowInputMethodForPassword() const;
98 
99  /**
100  * Show preedit when typing in password field.
101  *
102  * @return whether show preedit in password field.
103  * @since 5.1.2
104  */
105  bool showPreeditForPassword() const;
106 
107  /**
108  * Number of minutes that fcitx will automatically save user data.
109  *
110  * @return the period of auto save
111  * @since 5.1.2
112  */
113  int autoSavePeriod() const;
114 
115  /**
116  * Number of milliseconds that modifier only key can be triggered with key
117  * release.
118  *
119  * @return timeout
120  * @since 5.1.12
121  */
122  int modifierOnlyKeyTimeout() const;
123 
124  /**
125  * Helper function to check whether the modifier only key should be
126  * triggered.
127  *
128  * The user may need to record the time when the corresponding modifier only
129  * key is pressed. The input time should use CLOCK_MONOTONIC.
130  *
131  * If timeout < 0, always return true.
132  * Otherwise, check if it should be triggered based on current time.
133  *
134  * @return should trigger modifier only key
135  */
136  bool checkModifierOnlyKeyTimeout(uint64_t lastPressedTime) const;
137 
138  const std::vector<std::string> &enabledAddons() const;
139  const std::vector<std::string> &disabledAddons() const;
140 
141  void setEnabledAddons(const std::vector<std::string> &addons);
142  void setDisabledAddons(const std::vector<std::string> &addons);
143 
144  bool preloadInputMethod() const;
145 
146  void load(const RawConfig &rawConfig, bool partial = false);
147  void save(RawConfig &rawConfig) const;
148  bool safeSave(const std::string &path = "config") const;
149  const Configuration &config() const;
150  Configuration &config();
151 
152 private:
153  std::unique_ptr<GlobalConfigPrivate> d_ptr;
154  FCITX_DECLARE_PRIVATE(GlobalConfig);
155 };
156 } // namespace fcitx
157 
158 #endif // _FCITX_GLOBALCONFIG_H_
Definition: action.cpp:17
Class to represent a key.