| 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 KGLOBALSHORTCUT_H |
| 24 |
#define KGLOBALSHORTCUT_H |
| 25 |
|
| 26 |
#include <QObject> |
| 27 |
#ifdef _WIN32 |
| 28 |
#define KYSDK_EXPORT __declspec(dllexport) |
| 29 |
#else |
| 30 |
#define KYSDK_EXPORT __attribute__((visibility("default"))) |
| 31 |
#endif |
| 32 |
|
| 33 |
typedef struct _KYSDKGlobalShortcutInfoList KYSDKGlobalShortcutInfoList; |
| 34 |
namespace kdk |
| 35 |
{ |
| 36 |
/** |
| 37 |
* @defgroup ShortcutModule |
| 38 |
*/ |
| 39 |
|
| 40 |
/** |
| 41 |
* @brief 快捷键控制类, 提供快捷键管理功能 |
| 42 |
* @since 3.0.1.0 |
| 43 |
*/ |
| 44 |
class KYSDK_EXPORT KGlobalShortcut : public QObject |
| 45 |
{ |
| 46 |
Q_OBJECT |
| 47 |
public: |
| 48 |
explicit KGlobalShortcut(QObject *parent = nullptr); |
| 49 |
|
| 50 |
public: |
| 51 |
int creatGlobalShortcut(QString name, QString key, QString action); |
| 52 |
int deleteGlobalShortcut(QString name); |
| 53 |
int globalShortcutIsAvailable(QString key); |
| 54 |
int setGlobalShortcut(QString name, QString key, QString action); |
| 55 |
KYSDKGlobalShortcutInfoList *getGlobalShortcuts(); |
| 56 |
KYSDKGlobalShortcutInfoList *getGlobalShortcutByKey(QString key); |
| 57 |
QString numberToKey(uint number); |
| 58 |
uint keyToNumber(QString key); |
| 59 |
|
| 60 |
private: |
| 61 |
bool isKeyAvailable(const QKeySequence seq); |
| 62 |
bool isActionAvailable(const QString &action); |
| 63 |
QString convertKeyWithSeqString(QString key); |
| 64 |
QString convertKeyWithUsdString(QString key); |
| 65 |
|
| 66 |
private: |
| 67 |
int checkShortcutIsAvailable(QString key); |
| 68 |
int conflictWithGlobalShortcuts(const QKeySequence &keySequence); |
| 69 |
int conflictWithStandardShortcuts(const QKeySequence &keySequence); |
| 70 |
int conflictWithKysdkShortcuts(const QKeySequence &keySequence); |
| 71 |
}; |
| 72 |
} |
| 73 |
#endif // KGLOBALSHORTCUT_H |