Skip to content

Commit

Permalink
add hotkey method to Action (#1070)
Browse files Browse the repository at this point in the history
  • Loading branch information
eagleoflqj committed Jun 6, 2024
1 parent 7a43580 commit 63b2ba5
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
11 changes: 11 additions & 0 deletions src/lib/fcitx/action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class ActionPrivate : QPtrHolder<Action> {
int id_ = 0;
bool checkable_ = false;
bool separator_ = false;
KeyList hotkey_;
FCITX_DEFINE_SIGNAL_PRIVATE(Action, Update);
};

Expand Down Expand Up @@ -92,6 +93,16 @@ const std::string &Action::name() const {

void Action::update(InputContext *ic) { emit<Update>(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<Action> {
public:
SimpleActionPrivate(SimpleAction *q) : QPtrHolder(q) {}
Expand Down
19 changes: 19 additions & 0 deletions src/lib/fcitx/action.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

#include <memory>
#include <fcitx-utils/element.h>
#include <fcitx-utils/key.h>
#include <fcitx-utils/macros.h>
#include "fcitxcore_export.h"

Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 63b2ba5

Please sign in to comment.