Skip to content

Commit d2353c9

Browse files
committed
keyboard: simplify getKeySeq()
1 parent aa3f57e commit d2353c9

1 file changed

Lines changed: 25 additions & 29 deletions

File tree

src/controllers/keyboard/keyboardeventfilter.cpp

Lines changed: 25 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -127,40 +127,36 @@ bool KeyboardEventFilter::eventFilter(QObject*, QEvent* e) {
127127

128128
// static
129129
QKeySequence KeyboardEventFilter::getKeySeq(QKeyEvent* e) {
130-
QString modseq;
131-
QKeySequence k;
132-
133-
// TODO(XXX) check if we may simply return QKeySequence(e->modifiers()+e->key())
134-
135-
if (e->modifiers() & Qt::ShiftModifier) {
136-
modseq += "Shift+";
137-
}
138-
139-
if (e->modifiers() & Qt::ControlModifier) {
140-
modseq += "Ctrl+";
141-
}
142-
143-
if (e->modifiers() & Qt::AltModifier) {
144-
modseq += "Alt+";
145-
}
146-
147-
if (e->modifiers() & Qt::MetaModifier) {
148-
modseq += "Meta+";
149-
}
150-
151130
if (e->key() >= 0x01000020 && e->key() <= 0x01000023) {
152-
// Do not act on Modifier only
153-
// avoid returning "khmer vowel sign ie (U+17C0)"
154-
return k;
131+
// Do not act on Modifier only, avoid returning "khmer vowel sign ie (U+17C0)"
132+
return {};
155133
}
156134

157-
QString keyseq = QKeySequence(e->key()).toString();
158-
k = QKeySequence(modseq + keyseq);
159-
160135
if (CmdlineArgs::Instance().getDeveloper()) {
161-
qDebug() << "keyboard press: " << k.toString();
136+
QString modseq;
137+
QKeySequence k;
138+
if (e->modifiers() & Qt::ShiftModifier) {
139+
modseq += "Shift+";
140+
}
141+
if (e->modifiers() & Qt::ControlModifier) {
142+
modseq += "Ctrl+";
143+
}
144+
if (e->modifiers() & Qt::AltModifier) {
145+
modseq += "Alt+";
146+
}
147+
if (e->modifiers() & Qt::MetaModifier) {
148+
modseq += "Meta+";
149+
}
150+
QString keyseq = QKeySequence(e->key()).toString();
151+
k = QKeySequence(modseq + keyseq);
152+
if (e->type() == QEvent::KeyPress) {
153+
qDebug() << "keyboard press: " << k.toString();
154+
} else if (e->type() == QEvent::KeyRelease) {
155+
qDebug() << "keyboard release: " << k.toString();
156+
}
162157
}
163-
return k;
158+
159+
return QKeySequence(e->modifiers() + e->key());
164160
}
165161

166162
void KeyboardEventFilter::setKeyboardConfig(ConfigObject<ConfigValueKbd>* pKbdConfigObject) {

0 commit comments

Comments
 (0)