Fcitx
userinterfacemanager.h
Go to the documentation of this file.
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_USERINTERFACEMANAGER_H_
8 #define _FCITX_USERINTERFACEMANAGER_H_
9 
10 #include <memory>
11 #include <fcitx-utils/macros.h>
12 #include <fcitx/addonmanager.h>
13 #include <fcitx/fcitxcore_export.h>
14 #include <fcitx/inputpanel.h>
15 #include <fcitx/statusarea.h>
16 #include <fcitx/userinterface.h>
17 
18 /// \addtogroup FcitxCore
19 /// \{
20 /// \file
21 /// \brief Manager class for user interface.
22 
23 namespace fcitx {
24 
25 class UserInterfaceManagerPrivate;
26 
27 class FCITXCORE_EXPORT UserInterfaceManager {
28 public:
30  virtual ~UserInterfaceManager();
31 
32  /**
33  * Initialize the UI Addon
34  *
35  * If passed with a certain UI name, only that UI is treated as the usable
36  * UI.
37  * @arg ui addon name of the UI to be used.
38  */
39  void load(const std::string &ui = {});
40  /**
41  * Register an named action.
42  *
43  * The action should have a meaningful unique name.
44  * A common use case for the name is to allow an input method to enable a
45  * feature exposed by other addons.
46  * @arg name name of the action.
47  * @arg action action to be registered.
48  * @return whether action is registered successfully.
49  */
50  bool registerAction(const std::string &name, Action *action);
51  /**
52  * Register an anonymous action.
53  *
54  * @arg action action to be registered.
55  * @return whether action is registered successfully.
56  */
57  bool registerAction(Action *action);
58  /**
59  * Unregister the action.
60  */
61  void unregisterAction(Action *action);
62  /**
63  * Lookup an action by the name.
64  *
65  * Return null if action is not found.
66  * @return action
67  */
68  Action *lookupAction(const std::string &name) const;
69  /**
70  * Lookup an action by id.
71  *
72  * Return null if action is not found.
73  * @return action
74  */
75  Action *lookupActionById(int id) const;
76  /**
77  * Mark a user interface component to be updated for given input context.
78  *
79  * The update will not happen immediately.
80  * @arg component user interface component
81  * @arg inputContext Input Context
82  */
83  void update(UserInterfaceComponent component, InputContext *inputContext);
84  /**
85  * Remove all pending updates for a given input context.
86  */
87  void expire(InputContext *inputContext);
88  void flush();
89  /**
90  * Invoke by user interface addon to notify if there is any avaiability
91  * change.
92  */
93  void updateAvailability();
94  /**
95  * Return the current active addon ui name.
96  */
97  std::string currentUI() const;
98 
99  /**
100  * Return if virtual keyboard is visible.
101  */
102  bool isVirtualKeyboardVisible() const;
103  /**
104  * Show the virtual keyboard.
105  *
106  * This is a no-op if active addon is not a virtual keyboard addon.
107  */
108  void showVirtualKeyboard() const;
109  /**
110  * Hide the virtual keyboard.
111  *
112  * This is a no-op if active addon is not a virtual keyboard addon.
113  */
114  void hideVirtualKeyboard() const;
115 
116  /**
117  * Invoke by user interface addon to notify if there is any virtual keyboard
118  * visibility change.
119  *
120  * User interface addon must call this function to make user interface
121  * manager update its cached visibility.
122  */
123  void updateVirtualKeyboardVisibility();
124 
125 private:
126  std::unique_ptr<UserInterfaceManagerPrivate> d_ptr;
127  FCITX_DECLARE_PRIVATE(UserInterfaceManager);
128 };
129 } // namespace fcitx
130 
131 #endif // _FCITX_USERINTERFACEMANAGER_H_
Class for input panel in UI.
Definition: action.cpp:17
The Action class provides an abstraction for user commands that can be added to user interfaces...
Definition: action.h:34
Class for status area in UI.
Base class for User Interface addon.
UserInterfaceComponent
Definition: userinterface.h:21
An input context represents a client of Fcitx.
Definition: inputcontext.h:47
Addon Manager class.