| 126 | } |
| 127 | |
| 128 | bool QtKeypadBridge::keymapExport(const QString &path) { |
| 129 | if (!keymap) { |
| 130 | return false; |
| 131 | } |
| 132 | |
| 133 | QSettings config(path, QSettings::IniFormat); |
| 134 | config.clear(); |
| 135 | |
| 136 | for (unsigned row = 0; row < 8; ++row) { |
| 137 | for (unsigned col = 0; col < 8; ++col) { |
| 138 | QStringList nameBindings; |
| 139 | QStringList nativeCodeBindings; |
| 140 | QStringList nativeMaskBindings; |
| 141 | QStringList modifierBindings; |
| 142 | QStringList maskBindings; |
| 143 | for (const HostKey *key = keymap[row*8+col]; key->code; ++key) { |
| 144 | nameBindings.append(key->name); |
| 145 | nativeCodeBindings.append(QString::number(key->nativeCode, 16)); |
| 146 | nativeMaskBindings.append(QString::number(key->nativeMask, 16)); |
| 147 | modifierBindings.append(toModifierString(key->modifier)); |
| 148 | maskBindings.append(toModifierString(key->mask)); |
| 149 | } |
| 150 | if (!custom_keys[row][col].isEmpty()) { |
| 151 | config.setValue(custom_keys[row][col] + QStringLiteral("/keys"), nameBindings); |
| 152 | config.setValue(custom_keys[row][col] + QStringLiteral("/modifiers"), modifierBindings); |
| 153 | config.setValue(custom_keys[row][col] + QStringLiteral("/masks"), maskBindings); |
| 154 | config.setValue(custom_keys[row][col] + QStringLiteral("/native_codes"), nativeCodeBindings); |
| 155 | config.setValue(custom_keys[row][col] + QStringLiteral("/native_masks"), nativeMaskBindings); |
| 156 | } |
| 157 | } |
| 158 | } |
| 159 | |
| 160 | config.sync(); |
| 161 | return true; |
| 162 | } |
| 163 | |
| 164 | bool QtKeypadBridge::keymapImport(const QString &path) { |
| 165 | if (!fileExists(path)) { |