| 78 | } |
| 79 | |
| 80 | void EditKey::processKeyEvent(QKeyEvent * event) |
| 81 | { |
| 82 | // Only the modifier "Shift" is allowed |
| 83 | bool shiftModifier = (event->modifiers() & Qt::ShiftModifier) > 0; |
| 84 | |
| 85 | // Current key |
| 86 | QString key = QKeySequence(event->key()).toString(); |
| 87 | int keyNum = event->key(); |
| 88 | |
| 89 | // New text |
| 90 | if (key == "") |
| 91 | this->setText(shiftModifier ? "Shift+..." : "..."); |
| 92 | else |
| 93 | { |
| 94 | if (event->key() == Qt::Key_Shift) |
| 95 | this->setText(shiftModifier ? "Shift+..." : "..."); |
| 96 | else if (keyNum != Qt::Key_Control && keyNum != Qt::Key_Meta && keyNum != Qt::Key_Alt) |
| 97 | { |
| 98 | if (keyNum == Qt::Key_Delete) |
| 99 | { |
| 100 | // Reset the key |
| 101 | ContextManager::configuration()->setValue(ConfManager::SECTION_KEYBOARD, |
| 102 | "key_" + QString::number(_octave) + "_" + QString::number(_key), |
| 103 | ""); |
| 104 | this->setText(""); |
| 105 | } |
| 106 | else if (keyNum != Qt::Key_Escape && keyNum != Qt::Key_Return && keyNum != Qt::Key_Enter) |
| 107 | this->setText((shiftModifier ? "Shift+" : "") + key); |
| 108 | else |
| 109 | this->setText(""); |
| 110 | |
| 111 | this->clearFocus(); |
| 112 | this->updateText(); |
| 113 | } |
| 114 | } |
| 115 | } |
| 116 | |
| 117 | QSize EditKey::sizeHint() const |
| 118 | { |
nothing calls this directly
no test coverage detected