1 // copyright (c) 2021 hors<horsicq@gmail.com> 2 // 3 // Permission is hereby granted, free of charge, to any person obtaining a copy 4 // of this software and associated documentation files (the "Software"), to deal 5 // in the Software without restriction, including without limitation the rights 6 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 // copies of the Software, and to permit persons to whom the Software is 8 // furnished to do so, subject to the following conditions: 9 10 // The above copyright notice and this permission notice shall be included in all 11 // copies or substantial portions of the Software. 12 13 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 // SOFTWARE. 20 // 21 #ifndef XSHORTCUTS_H 22 #define XSHORTCUTS_H 23 24 #include <QMap> 25 #include <QDir> 26 #include <QSettings> 27 #include <QApplication> 28 #include <QKeySequence> 29 30 class XShortcuts : public QObject 31 { 32 Q_OBJECT 33 34 public: 35 enum GROUPID 36 { 37 GROUPID_UNKNOWN=0, 38 GROUPID_FILE, 39 GROUPID_VIEW, 40 GROUPID_DEBUGGER, 41 GROUPID_DEBUG, 42 GROUPID_ACTION, 43 GROUPID_STRINGS, 44 GROUPID_SIGNATURES, 45 GROUPID_HEX, 46 GROUPID_DISASM, 47 GROUPID_ARCHIVE, 48 GROUPID_TABLE, 49 }; 50 51 static const int GROUP_SH=24; 52 53 // TODO the subgroup 54 enum ID 55 { 56 ID_ACTION =GROUPID_ACTION<<GROUP_SH, 57 ID_ACTION_COPY, 58 ID_ACTION__END, 59 ID_STRINGS =GROUPID_STRINGS<<GROUP_SH, 60 ID_STRINGS_COPYSTRING, 61 ID_STRINGS_COPYOFFSET, 62 ID_STRINGS_COPYSIZE, 63 ID_STRINGS_HEX, 64 ID_STRINGS_DEMANGLE, 65 ID_STRINGS__END, 66 ID_SIGNATURES =GROUPID_SIGNATURES<<GROUP_SH, 67 ID_SIGNATURES_COPYNAME, 68 ID_SIGNATURES_COPYSIGNATURE, 69 ID_SIGNATURES_COPYADDRESS, 70 ID_SIGNATURES_COPYOFFSET, 71 ID_SIGNATURES_COPYSIZE, 72 ID_SIGNATURES_HEX, 73 ID_SIGNATURES__END, 74 ID_HEX =GROUPID_HEX<<GROUP_SH, 75 ID_HEX_DUMPTOFILE, 76 ID_HEX_GOTOOFFSET, 77 ID_HEX_GOTOADDRESS, 78 ID_HEX_SIGNATURE, 79 ID_HEX_FIND, 80 ID_HEX_FINDNEXT, 81 ID_HEX_SELECTALL, 82 ID_HEX_COPYASHEX, 83 ID_HEX_COPYCURSOROFFSET, 84 ID_HEX_COPYCURSORADDRESS, 85 ID_HEX_DISASM, 86 ID_HEX_MEMORYMAP, 87 ID_HEX__END, 88 ID_DISASM =GROUPID_DISASM<<GROUP_SH, 89 ID_DISASM_DUMPTOFILE, 90 ID_DISASM_GOTOADDRESS, 91 ID_DISASM_GOTOOFFSET, 92 ID_DISASM_GOTOENTRYPOINT, 93 ID_DISASM_HEXSIGNATURE, 94 ID_DISASM_SIGNATURE, 95 ID_DISASM_FIND, 96 ID_DISASM_FINDNEXT, 97 ID_DISASM_SELECTALL, 98 ID_DISASM_COPYASHEX, 99 ID_DISASM_COPYCURSORADDRESS, 100 ID_DISASM_COPYCURSOROFFSET, 101 ID_DISASM_HEX, 102 ID_DISASM__END, 103 ID_DEBUGGER =GROUPID_DEBUGGER<<GROUP_SH, 104 ID_DEBUGGER_FILE_OPEN, 105 ID_DEBUGGER_FILE_CLOSE, 106 ID_DEBUGGER_FILE_ATTACH, 107 ID_DEBUGGER_FILE_DETACH, 108 ID_DEBUGGER_FILE_EXIT, 109 ID_DEBUGGER_VIEW_CPU, 110 ID_DEBUGGER_VIEW_ACTIONS, 111 ID_DEBUGGER_VIEW_LOG, 112 ID_DEBUGGER_VIEW_BREAKPOINTS, 113 ID_DEBUGGER_VIEW_MEMORYMAP, 114 ID_DEBUGGER_VIEW_CALLSTACK, 115 ID_DEBUGGER_VIEW_THREADS, 116 ID_DEBUGGER_VIEW_HANDLES, 117 ID_DEBUGGER_DEBUG_RUN, 118 ID_DEBUGGER_DEBUG_PAUSE, 119 ID_DEBUGGER_DEBUG_SETREMOVEBREAKPOINT, 120 ID_DEBUGGER_DEBUG_STEPINTO, 121 ID_DEBUGGER_DEBUG_STEPOVER, 122 ID_DEBUGGER_DEBUG_STOP, 123 ID_DEBUGGER_DEBUG_RESTART, 124 ID_DEBUGGER_DISASM_DUMPTOFILE, 125 ID_DEBUGGER_DISASM_GOTOADDRESS, 126 ID_DEBUGGER_DISASM_HEXSIGNATURE, 127 ID_DEBUGGER_DISASM_SIGNATURE, 128 ID_DEBUGGER_DISASM_FIND, 129 ID_DEBUGGER_DISASM_FINDNEXT, 130 ID_DEBUGGER_DISASM_COPYASHEX, 131 ID_DEBUGGER_DISASM_COPYCURSORADDRESS, 132 ID_DEBUGGER_HEX_DUMPTOFILE, 133 ID_DEBUGGER_HEX_GOTOADDRESS, 134 ID_DEBUGGER__END, 135 ID_ARCHIVE =GROUPID_ARCHIVE<<GROUP_SH, 136 ID_ARCHIVE_OPEN, 137 ID_ARCHIVE_SCAN, 138 ID_ARCHIVE_HEX, 139 ID_ARCHIVE_STRINGS, 140 ID_ARCHIVE_ENTROPY, 141 ID_ARCHIVE_HASH, 142 ID_ARCHIVE_COPYFILENAME, 143 ID_ARCHIVE_DUMPTOFILE, 144 ID_ARCHIVE__END, 145 ID_TABLE =GROUPID_TABLE<<GROUP_SH, 146 ID_TABLE_HEX, 147 ID_TABLE_DISASM, 148 ID_TABLE__END 149 // TODO More 150 }; 151 152 explicit XShortcuts(QObject *pParent=nullptr); 153 void setName(QString sValue); 154 void setNative(bool bValue); 155 void addGroup(GROUPID groupId); 156 void addGroup(ID id); // TODO remove 157 void setShortcutsIDs(QList<ID> listValueIDs); 158 QList<ID> getShortcutsIDs(); 159 void load(); 160 void save(); 161 QKeySequence getShortcut(ID id); 162 void setShortcut(ID id,QKeySequence keyValue); 163 bool checkShortcut(ID id,QKeySequence keyValue); 164 165 static QString idToSettingsString(ID id); 166 static QString idToString(ID id); 167 static QKeySequence getDefault(ID id); 168 static QString groupIdToString(GROUPID groupId); 169 static ID getGroupEnd(GROUPID groupId); 170 static GROUPID getGroupId(ID id); 171 static GROUPID getSubgroupId(ID id); 172 173 private: 174 bool g_bIsNative; 175 QString g_sName; 176 QString g_sFilePath; 177 QList<ID> g_listValueIDs; 178 QMap<ID,QKeySequence> g_mapValues; 179 }; 180 181 #endif // XSHORTCUTS_H 182