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 
35  /**
36  * Consume Activate/Deactivate keys even when the state does not change.
37  *
38  * When enabled, pressing an activate key while the input method is
39  * already active (or a deactivate key while inactive) is consumed by
40  * fcitx instead of being forwarded to the application. Modifier only
41  * keys are not affected.
42  *
43  * @return whether to consume redundant activate/deactivate keys
44  * @since 5.1.22
45  */
46  bool consumeRedundantActivateKeys() const;
47  const KeyList &enumerateForwardKeys() const;
48  const KeyList &enumerateBackwardKeys() const;
49  bool enumerateSkipFirst() const;
50  const KeyList &enumerateGroupForwardKeys() const;
51  const KeyList &enumerateGroupBackwardKeys() const;
52  const KeyList &togglePreeditKeys() const;
53 
54  bool activeByDefault() const;
55 
56  /**
57  * Reset active state to the value of activeByDefault on Focus In.
58  *
59  * @see activeByDefault
60  * @return the reset policy, no for disable, all for always reset, program
61  * for only reset on program changes.
62  * @since 5.1.8
63  */
64  PropertyPropagatePolicy resetStateWhenFocusIn() const;
65  bool showInputMethodInformation() const;
66  bool showInputMethodInformationWhenFocusIn() const;
67  bool compactInputMethodInformation() const;
68  bool showFirstInputMethodInformation() const;
69  PropertyPropagatePolicy shareInputState() const;
70  bool preeditEnabledByDefault() const;
71 
72  const KeyList &defaultPrevPage() const;
73  const KeyList &defaultNextPage() const;
74 
75  const KeyList &defaultPrevCandidate() const;
76  const KeyList &defaultNextCandidate() const;
77  int defaultPageSize() const;
78 
79  /**
80  * Override the xkb option from display.
81  *
82  * This is only useful for custom xkb translation.
83  * Right now there is no way to read system xkb option from wayland.
84  * Instead, we can ask user for the fallback.
85  *
86  * @return override xkb option from system or not
87  * @since 5.0.14
88  */
89  bool overrideXkbOption() const;
90 
91  /**
92  * The enforce the xkb option for custom xkb state.
93  *
94  * This is only useful for custom xkb translation.
95  * Right now there is no way to read system xkb option from wayland.
96  * Instead, we can ask user for the fallback.
97  *
98  * @return override xkb option
99  * @see GlobalConfig::overrideXkbOption
100  * @since 5.0.14
101  */
102  const std::string &customXkbOption() const;
103 
104  /**
105  * Allow use input method in password field.
106  *
107  * @return whether allow use input method in password field.
108  * @since 5.1.2
109  */
110  bool allowInputMethodForPassword() const;
111 
112  /**
113  * Show preedit when typing in password field.
114  *
115  * @return whether show preedit in password field.
116  * @since 5.1.2
117  */
118  bool showPreeditForPassword() const;
119 
120  /**
121  * Number of minutes that fcitx will automatically save user data.
122  *
123  * @return the period of auto save
124  * @since 5.1.2
125  */
126  int autoSavePeriod() const;
127 
128  /**
129  * Number of milliseconds that modifier only key can be triggered with key
130  * release.
131  *
132  * @return timeout
133  * @since 5.1.12
134  */
135  int modifierOnlyKeyTimeout() const;
136 
137  /**
138  * Helper function to check whether the modifier only key should be
139  * triggered.
140  *
141  * The user may need to record the time when the corresponding modifier only
142  * key is pressed. The input time should use CLOCK_MONOTONIC.
143  *
144  * If timeout < 0, always return true.
145  * Otherwise, check if it should be triggered based on current time.
146  *
147  * @return should trigger modifier only key
148  */
149  bool checkModifierOnlyKeyTimeout(uint64_t lastPressedTime) const;
150 
151  const std::vector<std::string> &enabledAddons() const;
152  const std::vector<std::string> &disabledAddons() const;
153 
154  void setEnabledAddons(const std::vector<std::string> &addons);
155  void setDisabledAddons(const std::vector<std::string> &addons);
156 
157  bool preloadInputMethod() const;
158 
159  void load(const RawConfig &rawConfig, bool partial = false);
160  void save(RawConfig &rawConfig) const;
161  bool safeSave(const std::string &path = "config") const;
162  const Configuration &config() const;
163  Configuration &config();
164 
165 private:
166  std::unique_ptr<GlobalConfigPrivate> d_ptr;
167  FCITX_DECLARE_PRIVATE(GlobalConfig);
168 };
169 } // namespace fcitx
170 
171 #endif // _FCITX_GLOBALCONFIG_H_
A raw configuration tree that stores key-value pairs in a hierarchical structure. ...
Definition: rawconfig.h:37
Definition: action.cpp:17
Class to represent a key.