Showing the changes to libraries/script-engine/src/EventTypes.cpp (1 of 5 files). Show all
Unified · Split
| @@ -126,6 +126,30 @@ bool KeyEvent::operator==(const KeyEvent& other) const { · 125 unmodified lines | ||
| 126 | 126 | && other.isKeypad == isKeypad; |
| 127 | 127 | } |
| 128 | 128 | |
| 129 | + | |
| 130 | +KeyEvent::operator QKeySequence() const { | |
| 131 | + int resultCode = 0; | |
| 132 | + if (text >= "a" && text <= "z") { | |
| 133 | + resultCode = text.toUpper().at(0).unicode(); | |
| 134 | + } else { | |
| 135 | + resultCode = key; | |
| 136 | + } | |
| 137 | + | |
| 138 | + if (isMeta) { | |
| 139 | + resultCode |= Qt::META; | |
| 140 | + } | |
| 141 | + if (isAlt) { | |
| 142 | + resultCode |= Qt::ALT; | |
| 143 | + } | |
| 144 | + if (isControl) { | |
| 145 | + resultCode |= Qt::CTRL; | |
| 146 | + } | |
| 147 | + if (isShifted) { | |
| 148 | + resultCode |= Qt::SHIFT; | |
| 149 | + } | |
| 150 | + return QKeySequence(resultCode); | |
| 151 | +} | |
| 152 | + | |
| 129 | 153 | QScriptValue keyEventToScriptValue(QScriptEngine* engine, const KeyEvent& event) { |
| 130 | 154 | QScriptValue obj = engine->newObject(); |
| 131 | 155 | obj.setProperty("key", event.key); |