13 #include "fcitx-utils/macros.h" 24 bool checkable_ =
false;
25 bool separator_ =
false;
27 FCITX_DEFINE_SIGNAL_PRIVATE(
Action, Update);
30 Action::Action() : d_ptr(std::make_unique<ActionPrivate>(
this)) {}
32 Action::~Action() { destroy(); }
41 d->separator_ = separator;
50 void Action::setName(
const std::string &name) {
60 void Action::setId(
int id) {
67 d->checkable_ = checkable;
77 auto *oldMenu = this->menu();
79 oldMenu->removeParent(
this);
82 menu->addParent(
this);
87 auto childList = childs();
88 if (!childList.empty()) {
89 return static_cast<Menu *
>(childList.front());
115 std::string longText_;
116 std::string shortText_;
118 bool checked_ =
false;
121 SimpleAction::SimpleAction()
122 : d_ptr(std::make_unique<SimpleActionPrivate>(
this)) {}
126 void SimpleAction::setIcon(
const std::string &icon) {
131 void SimpleAction::setChecked(
bool checked) {
133 d->checked_ = checked;
136 void SimpleAction::setShortText(
const std::string &text) {
138 d->shortText_ = text;
141 void SimpleAction::setLongText(
const std::string &text) {
158 return d->shortText_;
167 emit<SimpleAction::Activated>(ic);
std::string icon(InputContext *) const override
Icon name of this action of given input context.
void activate(fcitx::InputContext *) override
Activate this action.
bool isChecked(InputContext *) const override
Return if this action is checked.
std::string shortText(InputContext *) const override
Short description for this action of given input context.
bool registerAction(const std::string &name, Action *action)
Register an named action.
Action & setSeparator(bool separator)
Set whether this action is a separator.
void setMenu(Menu *menu)
Set the sub menu of this action.
The Action class provides an abstraction for user commands that can be added to user interfaces...
bool registerAction(const std::string &name, UserInterfaceManager *uiManager)
Register an action to UserInterfaceManager.
void setHotkey(const KeyList &hotkey)
Set associated hotkey for display.
Utilities to enable use object with signal.
int id()
Return the unique integer id of action.
Manager class for user interface.
Action & setCheckable(bool checkable)
Set whether this action is a checkable action.
const KeyList & hotkey() const
Hotkey bound to the action.
bool isSeparator() const
Whether the action is a separator action.
#define FCITX_DEFINE_SIGNAL_PRIVATE(CLASS_NAME, NAME)
Declare a signal in pimpl class.
void update(InputContext *ic)
Notify that this action is required to be updated of given input context.
bool isCheckable() const
Whether the action is a checkable action.
const std::string & name() const
The action name when this action is registered.
std::string longText(InputContext *) const override
Return a long description for this action.
An input context represents a client of Fcitx.
Class to represent a key.
Menu * menu()
Return the sub menu of this action.