Debian Codegraph @

kysdk-shortcut/kdkshortcut/keybind.h

raw
1 /*
2 * libkysdk-shortcut's Library
3 *
4 * Copyright (C) 2025, KylinSoft Co., Ltd.
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 3 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this library. If not, see <https://www.gnu.org/licenses/>.
18 *
19 * Authors: ShaoShuai Tian <[email protected]>
20 *
21 */
22
23 #ifndef KEYBINDENTRY_H
24 #define KEYBINDENTRY_H
25
26 #include <QObject>
27 #include <QAction>
28 #include <KGlobalAccel>
29 #include <QDebug>
30
31 class Keybind : public QObject
32 {
33 Q_OBJECT
34 public:
35 Keybind(QString name, QString key, QString action, QString settingsPath, QString componentName, QObject *parent = nullptr);
36
37 public:
38 void reConnectAction();
39
40 public:
41 void setBindKey(QString bindKey) { mBindKey = bindKey; }
42 void setAction(QString execName) { mActionName = execName; }
43 QAction *action() { return mAction; }
44 QString settingPath() { return mSettingsPath; }
45 QString sctionName() { return mActionName; }
46
47 private:
48 void setUp();
49 void setShortcut();
50 void parsingDesktop(QString exec);
51 QList<QKeySequence> listFromString();
52
53 private slots:
54 void onActionTriggered();
55
56 private:
57 QString mActionName; // 名称唯一
58 QString mBindKey; // 绑定组合键
59 QString mActionCmd; // 组合键动作
60 QString mSettingsPath; // GSetting路径
61 QString mComponentName; // 组名称
62 QAction *mAction;
63 };
64
65 #endif // KEYBINDENTRY_H