diff --git a/kdevplatform/shell/sessionchooserdialog.cpp b/kdevplatform/shell/sessionchooserdialog.cpp --- a/kdevplatform/shell/sessionchooserdialog.cpp +++ b/kdevplatform/shell/sessionchooserdialog.cpp @@ -153,42 +153,37 @@ if(object == m_view && event->type() == QEvent::Leave ) { m_deleteButtonTimer.stop(); m_deleteButton->hide(); - } - if(object == m_filter && event->type() == QEvent::KeyPress) { + // don't eat the event, pass on + } else if (object == m_filter && event->type() == QEvent::KeyPress) { QKeyEvent *keyEvent = static_cast(event); - if(keyEvent->key() == Qt::Key_Up || keyEvent->key() == Qt::Key_Down || keyEvent->key() == Qt::Key_Return) { + if (keyEvent->key() == Qt::Key_Return) { + accept(); + // don't eat the event, pass on + } else if (keyEvent->key() == Qt::Key_Up || keyEvent->key() == Qt::Key_Down) { QModelIndex currentIndex = m_view->selectionModel()->currentIndex(); int selectRow = -1; - switch (keyEvent->key()) { - case Qt::Key_Up: + if (keyEvent->key() == Qt::Key_Up) { if(!currentIndex.isValid()) { selectRow = m_model->rowCount()-1; } else if(currentIndex.row()-1 >= 0) { selectRow = currentIndex.row()-1; } - break; - case Qt::Key_Down: + } else { if(!currentIndex.isValid()) { selectRow = 0; } else if(currentIndex.row()+1 < m_model->rowCount()) { selectRow = currentIndex.row()+1; } - break; - case Qt::Key_Return: - accept(); - return false; - default: - return false; } if (selectRow != -1) { m_view->selectionModel()->setCurrentIndex(m_model->index(selectRow, 0), QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows); } - return true; + return true; // eat event } } - return false; + return QDialog::eventFilter(object, event); } QWidget* SessionChooserDialog::mainWidget() const diff --git a/plugins/projectfilter/projectfilterconfigpage.cpp b/plugins/projectfilter/projectfilterconfigpage.cpp --- a/plugins/projectfilter/projectfilterconfigpage.cpp +++ b/plugins/projectfilter/projectfilterconfigpage.cpp @@ -110,23 +110,21 @@ bool ProjectFilterConfigPage::eventFilter(QObject* object, QEvent* event) { - Q_ASSERT(object == m_ui->filters); - Q_UNUSED(object); - if (event->type() == QEvent::KeyRelease) { + if (object == m_ui->filters && event->type() == QEvent::KeyRelease) { QKeyEvent* key = static_cast(event); if (key->key() == Qt::Key_Delete && key->modifiers() == Qt::NoModifier && m_ui->filters->currentIndex().isValid()) { // workaround https://bugs.kde.org/show_bug.cgi?id=324451 // there is no other way I see to figure out whether an editor is showing... QWidget* editor = m_ui->filters->viewport()->findChild(); - if (editor && editor->isVisible()) { - // editor is showing - return false; + if (!editor || !editor->isVisible()) { + // editor is not showing + remove(); + return true; // eat event } - remove(); - return true; } } - return false; + + return ProjectConfigPage::eventFilter(object, event); } void ProjectFilterConfigPage::selectionChanged() diff --git a/plugins/quickopen/quickopenplugin.cpp b/plugins/quickopen/quickopenplugin.cpp --- a/plugins/quickopen/quickopenplugin.cpp +++ b/plugins/quickopen/quickopenplugin.cpp @@ -1051,16 +1051,16 @@ bool QuickOpenLineEdit::eventFilter(QObject* obj, QEvent* e) { if (!m_widget) { - return false; + return IQuickOpenLine::eventFilter(obj, e); } switch (e->type()) { case QEvent::KeyPress: case QEvent::ShortcutOverride: if (static_cast(e)->key() == Qt::Key_Escape) { deactivate(); e->accept(); - return true; + return true; // eat event } break; case QEvent::WindowActivate: @@ -1085,13 +1085,13 @@ //Eat the focus event, keep the focus qCDebug(PLUGIN_QUICKOPEN) << "focus change" << "inside this: " << insideThis(obj) << "this" << this << "obj" << obj; if (obj == this) { - return false; + break; } qCDebug(PLUGIN_QUICKOPEN) << "reason" << focusEvent->reason(); if (focusEvent->reason() != Qt::MouseFocusReason && focusEvent->reason() != Qt::ActiveWindowFocusReason) { QMetaObject::invokeMethod(this, "checkFocus", Qt::QueuedConnection); - return false; + break; } if (!insideThis(obj)) { deactivate(); @@ -1103,7 +1103,8 @@ default: break; } - return false; + + return IQuickOpenLine::eventFilter(obj, e); } void QuickOpenLineEdit::activate() { diff --git a/plugins/quickopen/quickopenwidget.cpp b/plugins/quickopen/quickopenwidget.cpp --- a/plugins/quickopen/quickopenwidget.cpp +++ b/plugins/quickopen/quickopenwidget.cpp @@ -432,15 +432,15 @@ // Tab should work just like Down QCoreApplication::sendEvent(ui.list, new QKeyEvent(QEvent::KeyPress, Qt::Key_Down, Qt::NoModifier)); QCoreApplication::sendEvent(ui.list, new QKeyEvent(QEvent::KeyRelease, Qt::Key_Down, Qt::NoModifier)); - return true; + return true; // eat event } break; case Qt::Key_Backtab: if (keyEvent->modifiers() == Qt::ShiftModifier) { // Shift + Tab should work just like Up QCoreApplication::sendEvent(ui.list, new QKeyEvent(QEvent::KeyPress, Qt::Key_Up, Qt::NoModifier)); QCoreApplication::sendEvent(ui.list, new QKeyEvent(QEvent::KeyRelease, Qt::Key_Up, Qt::NoModifier)); - return true; + return true; // eat event } break; case Qt::Key_Down: @@ -453,62 +453,62 @@ } else { interface->up(); } - return true; + return true; // eat event } - return false; + break; } Q_FALLTHROUGH(); } case Qt::Key_PageUp: case Qt::Key_PageDown: if (watched == ui.list) { - return false; + break; } QApplication::sendEvent(ui.list, event); //callRowSelected(); - return true; + return true; // eat event case Qt::Key_Left: { //Expand/unexpand if (keyEvent->modifiers() == Qt::AltModifier) { //Eventually Send action to the widget if (auto interface = getInterface()) { interface->previous(); - return true; + return true; // eat event } } else { QModelIndex row = m_proxy->mapToSource(ui.list->currentIndex()); if (row.isValid()) { row = row.sibling(row.row(), 0); if (m_model->isExpanded(row)) { m_model->setExpanded(row, false); - return true; + return true; // eat event } } } - return false; + break; } case Qt::Key_Right: { //Expand/unexpand if (keyEvent->modifiers() == Qt::AltModifier) { //Eventually Send action to the widget if (auto interface = getInterface()) { interface->next(); - return true; + return true; // eat event } } else { QModelIndex row = m_proxy->mapToSource(ui.list->selectionModel()->currentIndex()); if (row.isValid()) { row = row.sibling(row.row(), 0); if (!m_model->isExpanded(row)) { m_model->setExpanded(row, true); - return true; + return true; // eat event } } } - return false; + break; } case Qt::Key_Return: case Qt::Key_Enter: { @@ -520,7 +520,7 @@ //Eventually Send action to the widget if (auto interface = getInterface()) { interface->accept(); - return true; + return true; // eat event } } else { QString filterText = ui.searchLine->text(); @@ -531,7 +531,7 @@ if (m_model->execute(m_proxy->mapToSource(ui.list->currentIndex()), filterText)) { if (!stillExists) { - return true; + return true; // eat event } if (!(keyEvent->modifiers() & Qt::ShiftModifier)) { @@ -544,12 +544,12 @@ } } } - return true; + return true; // eat event } } } - return false; + return QMenu::eventFilter(watched, event); } #include "quickopenwidget.moc"