MCPcopy Create free account
hub / github.com/davy7125/polyphone / processKeyEvent

Method processKeyEvent

sources/context/interface/editkey.cpp:80–115  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

78}
79
80void 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
117QSize EditKey::sizeHint() const
118{

Callers

nothing calls this directly

Calls 4

updateTextMethod · 0.95
setTextMethod · 0.80
toStringMethod · 0.45
setValueMethod · 0.45

Tested by

no test coverage detected