| 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 DCONFUTIL_H |
| 24 |
#define DCONFUTIL_H |
| 25 |
|
| 26 |
#include <QObject> |
| 27 |
|
| 28 |
/* qt会将glib里的signals成员识别为宏,所以取消该宏 |
| 29 |
* 后面如果用到signals时,使用Q_SIGNALS代替即可 |
| 30 |
**/ |
| 31 |
#ifdef signals |
| 32 |
#undef signals |
| 33 |
#endif |
| 34 |
|
| 35 |
extern "C" |
| 36 |
{ |
| 37 |
#include <gio/gio.h> |
| 38 |
#include <dconf/dconf.h> |
| 39 |
#include <dconf/client/dconf-client.h> |
| 40 |
#include <dconf/common/dconf-paths.h> |
| 41 |
} |
| 42 |
|
| 43 |
#define MAX_CUSTOM_SHORTCUTS 1000 |
| 44 |
#define KYSDK_KEYBINDINGS_DIR "/com/kylin/kysdk/keybindings/" |
| 45 |
#define KYSDK_KEYBINDING_SCHEMA "com.kylin.kysdk.keybinding" |
| 46 |
#define ACTION_KEY "action" |
| 47 |
#define BINDING_KEY "binding" |
| 48 |
#define NAME_KEY "name" |
| 49 |
|
| 50 |
typedef struct _KeyEntry |
| 51 |
{ |
| 52 |
QString gsSchema; |
| 53 |
QString gsPath; |
| 54 |
QString name; |
| 55 |
QString binding; |
| 56 |
QString action; |
| 57 |
} KeyEntry; |
| 58 |
|
| 59 |
class KShortcutUtil |
| 60 |
{ |
| 61 |
public: |
| 62 |
explicit KShortcutUtil(); |
| 63 |
|
| 64 |
public: |
| 65 |
QStringList listExistsShortcutPath(const char *dir); |
| 66 |
QString findFreePath(const char *dir); |
| 67 |
QString findTargetPath(QString name, const char *dir); |
| 68 |
QList<KeyEntry> getKysdkShortcuts(); |
| 69 |
}; |
| 70 |
|
| 71 |
#endif // DCONFUTIL_H |