diff --git a/CMakeLists.txt b/CMakeLists.txt index a66f3629..ac1e1dcb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.6.0) -project(fcitx VERSION 5.1.10) +project(fcitx VERSION 5.1.11) set(FCITX_VERSION ${PROJECT_VERSION}) find_package(ECM REQUIRED 1.0.0) diff --git a/src/lib/fcitx/action.cpp b/src/lib/fcitx/action.cpp index 84fa323e..67b21ffe 100644 --- a/src/lib/fcitx/action.cpp +++ b/src/lib/fcitx/action.cpp @@ -18,6 +18,7 @@ class ActionPrivate : QPtrHolder { int id_ = 0; bool checkable_ = false; bool separator_ = false; + KeyList hotkey_; FCITX_DEFINE_SIGNAL_PRIVATE(Action, Update); }; @@ -92,6 +93,16 @@ const std::string &Action::name() const { void Action::update(InputContext *ic) { emit(ic); } +const KeyList &Action::hotkey() const { + FCITX_D(); + return d->hotkey_; +} + +void Action::setHotkey(const KeyList &hotkey) { + FCITX_D(); + d->hotkey_ = hotkey; +} + class SimpleActionPrivate : public QPtrHolder { public: SimpleActionPrivate(SimpleAction *q) : QPtrHolder(q) {} diff --git a/src/lib/fcitx/action.h b/src/lib/fcitx/action.h index c6d0d02c..b840c89c 100644 --- a/src/lib/fcitx/action.h +++ b/src/lib/fcitx/action.h @@ -9,6 +9,7 @@ #include #include +#include #include #include "fcitxcore_export.h" @@ -139,6 +140,24 @@ class FCITXCORE_EXPORT Action : public Element { FCITX_DECLARE_SIGNAL(Action, Update, void(InputContext *)); + /** + * Hotkey bound to the action. + * This is only for display purpose when UI implementation supports it, + * and it has nothing to do with the key handling logic. + * + * @return key list. + * @since 5.1.11 + */ + const KeyList &hotkey() const; + + /** + * Set associated hotkey for display. + * + * @param hotkey keys that trigger the action. + * @since 5.1.11 + */ + void setHotkey(const KeyList &hotkey); + private: void setName(const std::string &name); void setId(int id);