Fcitx
statusarea.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2017-2017 CSSlayer <wengxt@gmail.com>
3  *
4  * SPDX-License-Identifier: LGPL-2.1-or-later
5  *
6  */
7 #ifndef _FCITX_STATUSAREA_H_
8 #define _FCITX_STATUSAREA_H_
9 
10 #include <memory>
11 #include <vector>
12 #include <fcitx-utils/element.h>
13 #include <fcitx-utils/macros.h>
14 #include <fcitx/fcitxcore_export.h>
15 
16 /// \addtogroup FcitxCore
17 /// \{
18 /// \file
19 /// \brief Class for status area in UI.
20 
21 namespace fcitx {
22 
23 class Action;
24 class StatusAreaPrivate;
25 class InputContext;
26 
27 enum class StatusGroup {
28  /// Action shown before input method group.
30  /// Group should be solely used by input method engine.
31  /// It will be cleared automatically before InputMethodEngine::activate.
32  /// @see InputMethodEngine::activate
33  InputMethod,
34  /// Action shown after input method group.
36 };
37 
38 /**
39  * Status area represent a list of actions and action may have sub actions.
40  *
41  * StatusArea can be shown as a floating window, embedded button in panel, or a
42  * tray menu. The actual representation is up to UI plugin.
43  */
44 class FCITXCORE_EXPORT StatusArea : public Element {
45 public:
46  /// Construct status area for associated input context.
48  ~StatusArea();
49 
50  /// Add an action to given group.
51  void addAction(StatusGroup group, Action *action);
52 
53  /// Remove an action from given group.
54  void removeAction(Action *action);
55 
56  /// Clear all the actions, will be called when input context lost focus.
57  void clear();
58 
59  /// Clear only given status group.
60  void clearGroup(StatusGroup group);
61 
62  /// Get the associated actions for group.
63  std::vector<Action *> actions(StatusGroup group) const;
64 
65  /// Get all the associated actions.
66  std::vector<Action *> allActions() const;
67 
68 private:
69  std::unique_ptr<StatusAreaPrivate> d_ptr;
70  FCITX_DECLARE_PRIVATE(StatusArea);
71 };
72 } // namespace fcitx
73 
74 #endif // _FCITX_STATUSAREA_H_
Utility class that provides a hierarchy between multiple objects.
Definition: action.cpp:17
The Action class provides an abstraction for user commands that can be added to user interfaces...
Definition: action.h:34
Action shown before input method group.
StatusGroup
Definition: statusarea.h:27
Status area represent a list of actions and action may have sub actions.
Definition: statusarea.h:44
Action shown after input method group.
An input context represents a client of Fcitx.
Definition: inputcontext.h:47
Base class that can be used for UI composition or graph.
Definition: element.h:26